use of maspack.geometry.QuadBezierDistance2d in project artisynth_core by artisynth.
the class NURBSCurve2dTest method addTestCurves.
public void addTestCurves() {
Vector4d[] q4 = new Vector4d[] { new Vector4d(300, 100, 0, 1), new Vector4d(300, 300, 0, 1), new Vector4d(100, 300, 0, 1), new Vector4d(100, 100, 0, 1) };
double[] k4 = new double[] { -2, -1, 0, 1, 2, 3, 4, 5, 6 };
Vector4d[] qclosed = new Vector4d[] { new Vector4d(150, 50, 0, 1), new Vector4d(250, 50, 0, 1), new Vector4d(300, 100, 0, 1), new Vector4d(350, 150, 0, 1), new Vector4d(350, 250, 0, 1), new Vector4d(300, 300, 0, 1), new Vector4d(250, 350, 0, 1), new Vector4d(150, 350, 0, 1), new Vector4d(100, 300, 0, 1), new Vector4d(50, 250, 0, 1), new Vector4d(50, 150, 0, 1), new Vector4d(100, 100, 0, 1) };
double[] kclosed = new double[] { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5 };
Vector4d[] qopen = new Vector4d[] { new Vector4d(100, 100, 0, 1), new Vector4d(150, 50, 0, 1), new Vector4d(250, 50, 0, 1), new Vector4d(300, 100, 0, 1), new Vector4d(350, 150, 0, 1), new Vector4d(350, 250, 0, 1), new Vector4d(300, 300, 0, 1), new Vector4d(250, 350, 0, 1), new Vector4d(150, 350, 0, 1), new Vector4d(100, 300, 0, 1), new Vector4d(50, 250, 0, 1), new Vector4d(50, 150, 0, 1), new Vector4d(100, 100, 0, 1) };
double[] kopen = new double[] { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11 };
Vector4d[] qsimple = new Vector4d[] { new Vector4d(100, 100, 0, 1), new Vector4d(200, 100, 0, 1), new Vector4d(200, 200, 0, 1), new Vector4d(200, 300, 0, 1), new Vector4d(100, 300, 0, 1), new Vector4d(50, 200, 0, 1) };
double[] ksimple = new double[] { 0, 0, 1, 1 };
// NURBSCurve2d curve = new NURBSCurve2d (2, NURBSCurve2d.CLOSED, q4, null);
NURBSCurve2d curve = new NURBSCurve2d(2, NURBSCurve2d.CLOSED, qsimple, null);
curve.convertToBezier();
writeCurve("curve.txt", curve);
NURBSCurve2d curve2 = readCurve("curve.txt");
NURBSCurve2d check = new NURBSCurve2d(3, NURBSCurve2d.CLOSED, q4, null);
check.transform(new RigidTransform3d(300, 0, 0));
DistanceGrid grid = new DistanceGrid(150, 200, 500, 500, 51, 51);
grid.update(curve2, 50);
QuadBezierDistance2d dist = new QuadBezierDistance2d(curve2);
Vector2d pnt = new Vector2d(250, 200);
Vector2d near = new Vector2d();
double d = dist.computeDistance(near, pnt, 1e10);
System.out.println("max curvature=" + dist.computeMaxCurvature());
myFrame.addRenderable(curve2);
myFrame.addRenderable(grid);
}
Aggregations