public void SetLocation(Point p) { this.x = p.GetX(); this.y = p.GetY(); }
public int DistanceTo(Point p) { int tx = (int) (this.x - p.x); int ty = (int) (this.y - p.y); return Loon.Utils.MathUtils.Sqrt(Loon.Utils.MathUtils.Mul(tx, tx) + Loon.Utils.MathUtils.Mul(ty, ty)); }
public void GetLocation(Point dest) { dest.SetLocation(this.x, this.y); }
public Point(Point p) { this.CheckPoints(); this.SetLocation(p); this.type = Loon.Core.Geom.ShapeType.POINT_SHAPE; }
public void Set(Point.Point2i p) { this.x = p.x; this.y = p.y; }
public int DistanceTo(Point.Point2i p) { int tx = this.x - p.x; int ty = this.y - p.y; return Loon.Utils.MathUtils .Sqrt(Loon.Utils.MathUtils.Mul(tx, tx) + Loon.Utils.MathUtils.Mul(ty, ty)); }
public int DistanceTo(Point.Point2i p1, Point.Point2i p2) { int tx = p2.x - p1.x; int ty = p2.y - p1.y; int u = Loon.Utils.MathUtils.Div( Loon.Utils.MathUtils.Mul(x - p1.x, tx) + Loon.Utils.MathUtils.Mul(y - p1.y, ty), Loon.Utils.MathUtils.Mul(tx, tx) + Loon.Utils.MathUtils.Mul(ty, ty)); int ix = p1.x + Loon.Utils.MathUtils.Mul(u, tx); int iy = p1.y + Loon.Utils.MathUtils.Mul(u, ty); int dx = ix - x; int dy = iy - y; return Loon.Utils.MathUtils .Sqrt(Loon.Utils.MathUtils.Mul(dx, dx) + Loon.Utils.MathUtils.Mul(dy, dy)); }
public void Untranslate(Point p) { this.x -= p.x; this.y -= p.y; }
public Point2i(Point.Point2i p) { this.x = p.x; this.y = p.y; }
public Point(Point p) { this.CheckPoints(); this.SetLocation(p); this.type = ShapeType.POINT_SHAPE; }
public void Translate(Point p) { this.x += p.x; this.y += p.y; }
public static Polygon MakePolygon(int[] pixels, int offsetX, int offsetY, int startX, int startY, int limitX, int limitY, int interval) { Polygon split = null; Polygon result = null; List<Point[]> points = new List<Point[]>(); Point[] tmpPoint; int x1, y1, x2, y2; bool secondPoint; int pixel = 0; for (int y = startY; y < limitY - interval; y += interval) { secondPoint = false; x1 = y1 = -1; x2 = y2 = -1; for (int x = startX; x < limitX; x++) { pixel = pixels[x + limitX * y]; if (!secondPoint) { if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT) { x1 = x; y1 = y; secondPoint = true; } } else { if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT) { x2 = x; y2 = y; } } } if (secondPoint && (x2 > -1) && (y2 > -1)) { tmpPoint = new Point[2]; tmpPoint[0] = new Point(offsetX + x1, offsetY + y1); tmpPoint[1] = new Point(offsetX + x2, offsetY + y2); CollectionUtils.Add(points,tmpPoint); } } split = MakePolygon(points); if (split != null) { points = new List<Point[]>(); for (int x_0 = startX; x_0 < limitX - interval; x_0 += interval) { secondPoint = false; x1 = y1 = -1; x2 = y2 = -1; for (int y_1 = startY; y_1 < limitY; y_1++) { pixel = pixels[x_0 + limitX * y_1]; if (!secondPoint) { if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT) { x1 = x_0; y1 = y_1; secondPoint = true; } } else { if ((pixel & LSystem.TRANSPARENT) == LSystem.TRANSPARENT) { x2 = x_0; y2 = y_1; } } } if (secondPoint && (x2 > -1) && (y2 > -1)) { tmpPoint = new Point[2]; tmpPoint[0] = new Point(offsetX + x1, offsetY + y1); tmpPoint[1] = new Point(offsetX + x2, offsetY + y2); CollectionUtils.Add(points, tmpPoint); } } result = MakePolygon(points); } return result; }
public float PtSegDistSq(Point pt) { return PtSegDistSq(GetX1(), GetY1(), GetX2(), GetY2(), pt.GetX(), pt.GetY()); }
public float PtLineDist(Point pt) { return PtLineDist(GetX1(), GetY1(), GetX2(), GetY2(), pt.GetX(), pt.GetY()); }
public Line(Point p1, Point p2) : this(p1.x, p1.y, p2.x, p2.y) { }
public Point(Point p) { this.CheckPoints(); this.SetLocation(p); }