internal StandardLine(Point p1, Point p2) { // Constants from the standard line representation: Ax+By+C A = (float)(p2.GetY() - p1.GetY()); B = (float)(p1.GetX() - p2.GetX()); C = (float)(p1.GetY() * (-B) - p1.GetX() * A); }
private static Point[] GetRotatedSquareVertices(Point[] orthogonalSquareVertices, double angle, Point squareCenter ) { Point[] rotatedSquareVertices = new Point[orthogonalSquareVertices.Length]; AffineTransform.GetRotateInstance((float)angle).Transform(orthogonalSquareVertices, 0, rotatedSquareVertices , 0, rotatedSquareVertices.Length); AffineTransform.GetTranslateInstance((float)squareCenter.GetX(), (float)squareCenter.GetY()).Transform(rotatedSquareVertices , 0, rotatedSquareVertices, 0, orthogonalSquareVertices.Length); return(rotatedSquareVertices); }
/// <summary>Convert 4 Point objects into a Rectangle</summary> /// <param name="p1">first Point</param> /// <param name="p2">second Point</param> /// <param name="p3">third Point</param> /// <param name="p4">fourth Point</param> private Rectangle GetAsRectangle(Point p1, Point p2, Point p3, Point p4) { IList <double> xs = JavaUtil.ArraysAsList(p1.GetX(), p2.GetX(), p3.GetX(), p4.GetX()); IList <double> ys = JavaUtil.ArraysAsList(p1.GetY(), p2.GetY(), p3.GetY(), p4.GetY()); double left = Enumerable.Min(xs); double bottom = Enumerable.Min(ys); double right = Enumerable.Max(xs); double top = Enumerable.Max(ys); return(new Rectangle((float)left, (float)bottom, (float)(right - left), (float)(top - bottom))); }
/// <summary>Approximate a circle with 4 Bezier curves (one for each 90 degrees sector)</summary> /// <param name="center">center of the circle</param> /// <param name="radius">radius of the circle</param> private static BezierCurve[] ApproximateCircle(Point center, double radius) { // The circle is split into 4 sectors. Arc of each sector // is approximated with bezier curve separately. BezierCurve[] approximation = new BezierCurve[4]; double x = center.GetX(); double y = center.GetY(); approximation[0] = new BezierCurve(JavaUtil.ArraysAsList(new Point(x, y + radius), new Point(x + radius * CIRCLE_APPROXIMATION_CONST, y + radius), new Point(x + radius, y + radius * CIRCLE_APPROXIMATION_CONST ), new Point(x + radius, y))); approximation[1] = new BezierCurve(JavaUtil.ArraysAsList(new Point(x + radius, y), new Point(x + radius, y - radius * CIRCLE_APPROXIMATION_CONST), new Point(x + radius * CIRCLE_APPROXIMATION_CONST, y - radius ), new Point(x, y - radius))); approximation[2] = new BezierCurve(JavaUtil.ArraysAsList(new Point(x, y - radius), new Point(x - radius * CIRCLE_APPROXIMATION_CONST, y - radius), new Point(x - radius, y - radius * CIRCLE_APPROXIMATION_CONST ), new Point(x - radius, y))); approximation[3] = new BezierCurve(JavaUtil.ArraysAsList(new Point(x - radius, y), new Point(x - radius, y + radius * CIRCLE_APPROXIMATION_CONST), new Point(x - radius * CIRCLE_APPROXIMATION_CONST, y + radius ), new Point(x, y + radius))); return(approximation); }
/// <summary>Sets the start point of the subpath.</summary> /// <param name="startPoint">the point this subpath starts at</param> public virtual void SetStartPoint(Point startPoint) { SetStartPoint((float)startPoint.GetX(), (float)startPoint.GetY()); }
/// <summary>Constructs a new subpath starting at the given point.</summary> /// <param name="startPoint">the point this subpath starts at</param> public Subpath(Point startPoint) : this((float)startPoint.GetX(), (float)startPoint.GetY()) { }
/// <summary>Constructs a new line based on the given coordinates.</summary> /// <param name="p1">start point of this Line</param> /// <param name="p2">end point of this Line</param> public Line(Point p1, Point p2) : this((float)p1.GetX(), (float)p1.GetY(), (float)p2.GetX(), (float)p2.GetY()) { }
internal virtual bool Contains(Point point) { return(JavaUtil.FloatCompare(Math.Abs(A * (float)point.GetX() + B * (float)point.GetY() + C), 0.1f) < 0); }