virtual public Point2D InverseTransform(Point2D src, Point2D dst) { double det = GetDeterminant(); if (Math.Abs(det) < ZERO) { // awt.204=Determinant is zero throw new InvalidOperationException("awt.204"); //$NON-NLS-1$ } if (dst == null) { if (src is Point2D.Double) { dst = new Point2D.Double(); } else { dst = new Point2D.Float(); } } double x = src.GetX() - m02; double y = src.GetY() - m12; dst.SetLocation((x * m11 - y * m01) / det, (y * m00 - x * m10) / det); return(dst); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj is Point2D) { Point2D p = (Point2D)obj; return(GetX() == p.GetX() && GetY() == p.GetY()); } return(false); }
virtual public Point2D DeltaTransform(Point2D src, Point2D dst) { if (dst == null) { if (src is Point2D.Double) { dst = new Point2D.Double(); } else { dst = new Point2D.Float(); } } double x = src.GetX(); double y = src.GetY(); dst.SetLocation(x * m00 + y * m01, x * m10 + y * m11); return dst; }
virtual public void Transform(Point2D[] src, int srcOff, Point2D[] dst, int dstOff, int length) { while (--length >= 0) { Point2D srcPoint = src[srcOff++]; double x = srcPoint.GetX(); double y = srcPoint.GetY(); Point2D dstPoint = dst[dstOff]; if (dstPoint == null) { if (srcPoint is Point2D.Double) { dstPoint = new Point2D.Double(); } else { dstPoint = new Point2D.Float(); } } dstPoint.SetLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); dst[dstOff++] = dstPoint; } }
public Point2D Transform(Point2D src, Point2D dst) { if (dst == null) { if (src is Point2D.Double) { dst = new Point2D.Double(); } else { dst = new Point2D.Float(); } } double x = src.GetX(); double y = src.GetY(); dst.SetLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); return(dst); }
/** * Sets the start point of the subpath. * @param startPoint */ public virtual void SetStartPoint(Point2D startPoint) { SetStartPoint((float) startPoint.GetX(), (float) startPoint.GetY()); }
virtual public void SetLocation(Point2D p) { SetLocation(p.GetX(), p.GetY()); }
internal bool Contains(Point2D point) { return Util.compare(Math.Abs(A * (float) point.GetX() + B * (float) point.GetY() + C), 0.1f) < 0; }
/** * Constructs a new line based on the given coordinates. */ public Line(Point2D p1, Point2D p2) : this((float) p1.GetX(), (float) p1.GetY(), (float) p2.GetX(), (float) p2.GetY()) { }
public virtual bool Contains(Point2D point) { return Contains(point.GetX(), point.GetY()); }
internal StandardLine(Point2D p1, Point2D p2) { A = (float) (p2.GetY() - p1.GetY()); B = (float) (p1.GetX() - p2.GetX()); C = (float) (p1.GetY() * (-B) - p1.GetX() * A); }
/** * Constructs a new subpath starting at the given point. */ public Subpath(Point2D startPoint) : this((float) startPoint.GetX(), (float) startPoint.GetY()) { }
virtual public double DistanceSq(Point2D p) { return(Point2D.DistanceSq(GetX(), GetY(), p.GetX(), p.GetY())); }
private Rectangle GetRectangle(Point2D p1, Point2D p2, Point2D p3, Point2D p4) { double[] xs = { p1.GetX(), p2.GetX(), p3.GetX(), p4.GetX() }; double[] ys = { p1.GetY(), p2.GetY(), p3.GetY(), p4.GetY() }; double left = Util.Min(xs); double bottom = Util.Min(ys); double right = Util.Max(xs); double top = Util.Max(ys); return new Rectangle((float)left, (float)bottom, (float)right, (float)top); }
private static Point2D GetNextPoint(Point2D segStart, Point2D segEnd, float dist) { Point2D vector = ComponentwiseDiff(segEnd, segStart); Point2D unitVector = GetUnitVector(vector); return new Point2D.Float((float) (segStart.GetX() + dist * unitVector.GetX()), (float) (segStart.GetY() + dist * unitVector.GetY())); }
private static BezierCurve[] ApproximateCircle(Point2D 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(new List<Point2D>(new Point2D[] { new Point2D.Double(x, y + radius), new Point2D.Double(x + radius * circleApproximationConst, y + radius), new Point2D.Double(x + radius, y + radius * circleApproximationConst), new Point2D.Double(x + radius, y) })); approximation[1] = new BezierCurve(new List<Point2D>(new Point2D[] { new Point2D.Double(x + radius, y), new Point2D.Double(x + radius, y - radius * circleApproximationConst), new Point2D.Double(x + radius * circleApproximationConst, y - radius), new Point2D.Double(x, y - radius) })); approximation[2] = new BezierCurve(new List<Point2D>(new Point2D[] { new Point2D.Double(x, y - radius), new Point2D.Double(x - radius * circleApproximationConst, y - radius), new Point2D.Double(x - radius, y - radius * circleApproximationConst), new Point2D.Double(x - radius, y) })); approximation[3] = new BezierCurve(new List<Point2D>(new Point2D[] { new Point2D.Double(x - radius, y), new Point2D.Double(x - radius, y + radius * circleApproximationConst), new Point2D.Double(x - radius * circleApproximationConst, y + radius), new Point2D.Double(x, y + radius) })); return approximation; }
private static Point2D[] GetRotatedSquareVertices(Point2D[] orthogonalSquareVertices, double angle, Point2D squareCenter) { Point2D[] rotatedSquareVertices = new Point2D[orthogonalSquareVertices.Length]; AffineTransform.GetRotateInstance(angle). Transform(orthogonalSquareVertices, 0, rotatedSquareVertices, 0, rotatedSquareVertices.Length); AffineTransform.GetTranslateInstance(squareCenter.GetX(), squareCenter.GetY()). Transform(rotatedSquareVertices, 0, rotatedSquareVertices, 0, orthogonalSquareVertices.Length); return rotatedSquareVertices; }
private void WriteMoveTo(Point2D destinationPoint, PdfContentByte canvas) { new PdfNumber(destinationPoint.GetX()).ToPdf(canvas.PdfWriter, canvas.InternalBuffer); canvas.InternalBuffer.Append(' '); new PdfNumber(destinationPoint.GetY()).ToPdf(canvas.PdfWriter, canvas.InternalBuffer); canvas.InternalBuffer.Append(m); }
virtual public double DistanceSq(Point2D p) { return Point2D.DistanceSq(GetX(), GetY(), p.GetX(), p.GetY()); }
private static Point2D GetUnitVector(Point2D vector) { double vectorLength = GetVectorEuclideanNorm(vector); return new Point2D.Float((float) (vector.GetX() / vectorLength), (float) (vector.GetY() / vectorLength)); }
private static bool LiesOnSegment(Point2D segStart, Point2D segEnd, Point2D point) { return point.GetX() >= Math.Min(segStart.GetX(), segEnd.GetX()) && point.GetX() <= Math.Max(segStart.GetX(), segEnd.GetX()) && point.GetY() >= Math.Min(segStart.GetY(), segEnd.GetY()) && point.GetY() <= Math.Max(segStart.GetY(), segEnd.GetY()); }
private static Point2D ComponentwiseDiff(Point2D minuend, Point2D subtrahend) { return new Point2D.Float((float) (minuend.GetX() - subtrahend.GetX()), (float) (minuend.GetY() - subtrahend.GetY())); }
virtual public Point2D InverseTransform(Point2D src, Point2D dst) { double det = GetDeterminant(); if (Math.Abs(det) < ZERO) { // awt.204=Determinant is zero throw new InvalidOperationException("awt.204"); //$NON-NLS-1$ } if (dst == null) { if (src is Point2D.Double) { dst = new Point2D.Double(); } else { dst = new Point2D.Float(); } } double x = src.GetX() - m02; double y = src.GetY() - m12; dst.SetLocation((x * m11 - y * m01) / det, (y * m00 - x * m10) / det); return dst; }