private static Subpath ConstructSquare(Point2D squareCenter, double widthHalf, double rotationAngle) { // Orthogonal square is the square with sides parallel to one of the axes. Point2D[] ortogonalSquareVertices = { new Point2D.Double(-widthHalf, -widthHalf), new Point2D.Double(-widthHalf, widthHalf), new Point2D.Double(widthHalf, widthHalf), new Point2D.Double(widthHalf, -widthHalf) }; Point2D[] rotatedSquareVertices = GetRotatedSquareVertices(ortogonalSquareVertices, rotationAngle, squareCenter); Subpath square = new Subpath(); square.AddSegment(new Line(rotatedSquareVertices[0], rotatedSquareVertices[1])); square.AddSegment(new Line(rotatedSquareVertices[1], rotatedSquareVertices[2])); square.AddSegment(new Line(rotatedSquareVertices[2], rotatedSquareVertices[3])); square.AddSegment(new Line(rotatedSquareVertices[3], rotatedSquareVertices[0])); return square; }
/** * Converts specified degenerate subpaths to circles. * Note: actually the resultant subpaths are not real circles but approximated. * * @param radius Radius of each constructed circle. * @return {@link java.util.List} consisting of circles constructed on given degenerated subpaths. */ private static IList<Subpath> ConvertToCircles(IList<Subpath> degenerateSubpaths, double radius) { IList<Subpath> circles = new List<Subpath>(degenerateSubpaths.Count); foreach (Subpath subpath in degenerateSubpaths) { BezierCurve[] circleSectors = ApproximateCircle(subpath.GetStartPoint(), radius); Subpath circle = new Subpath(); circle.AddSegment(circleSectors[0]); circle.AddSegment(circleSectors[1]); circle.AddSegment(circleSectors[2]); circle.AddSegment(circleSectors[3]); circles.Add(circle); } return circles; }