Coordinate center = arc.getCenter(); double radius = arc.getRadius(); double[] cp = arc.getControlPoints(); double angle1 = Math.atan2(cp[1] - center.y, cp[0] - center.x); double angle2 = Math.atan2(cp[3] - center.y, cp[2] - center.x);
@Test public void testNormalize() { double[] circleControlPoints = new double[] {0, 0, 0, 10, 0, 0}; CircularRing circle = new CircularRing(circleControlPoints, GEOMETRY_FACTORY, 1e-6); CircularRing normalized = circle.normalizeRing(); assertEquals(2, normalized.getNumArcs()); CircularArc a1 = normalized.getArcN(0); assertArrayEquals(new double[] {0, 0, 5, 5, 0, 10}, a1.getControlPoints(), 1e-6); CircularArc a2 = normalized.getArcN(1); assertArrayEquals(new double[] {0, 10, -5, 5, 0, 0}, a2.getControlPoints(), 1e-6); }
@Test public void testMatchingSequence() { Circle circle = new Circle(100); // create control points that will match exactly the points the algo should generate CircularArc arc = circle.getCircularArc(0, CircularArc.HALF_PI / 32, CircularArc.HALF_PI / 16); assertEquals(100, arc.getRadius(), 1e-9); assertCoordinateEquals(ORIGIN, arc.getCenter()); // linearize with a large tolerance, we should get back just the control points assertArrayEquals(arc.getControlPoints(), arc.linearize(10), 0d); }
@Test public void testMinuscule() { Circle circle = new Circle(100); CircularArc arc = circle.getCircularArc(0, CircularArc.HALF_PI / 128, CircularArc.HALF_PI / 64); assertEquals(100, arc.getRadius(), 1e-9); assertCoordinateEquals(ORIGIN, arc.getCenter()); // linearize with a large tolerance, we should get back just the control points assertArrayEquals(arc.getControlPoints(), arc.linearize(10), 0d); assertEquals(envelopeFrom(arc), arc.getEnvelope()); }