public void DrawPolygon(Polygon.Polygon2i p) { DrawPolygon(p.xpoints, p.ypoints, p.npoints); }
public void FillPolygon(Polygon.Polygon2i p) { FillPolygon(p.xpoints, p.ypoints, p.npoints); }
public override Shape Transform(Matrix transform) { CheckPoints(); Polygon resultPolygon = new Polygon(); float[] result = new float[points.Length]; transform.Transform(points, 0, result, 0, points.Length / 2); resultPolygon.points = result; resultPolygon.CheckPoints(); return resultPolygon; }
public Shape GetShape() { if (isUpdate) { Setup(); poly = new Polygon(); /* foreach */ foreach (CycleProgress point in points) { poly.AddPoint(point.x, point.y); } } return poly; }
public Shape Prune() { Polygon result = new Polygon(); for (int i = 0; i < GetPointCount(); i++) { int next = (i + 1 >= GetPointCount()) ? 0 : i + 1; int prev = (i - 1 < 0) ? GetPointCount() - 1 : i - 1; float dx1 = GetPoint(i)[0] - GetPoint(prev)[0]; float dy1 = GetPoint(i)[1] - GetPoint(prev)[1]; float dx2 = GetPoint(next)[0] - GetPoint(i)[0]; float dy2 = GetPoint(next)[1] - GetPoint(i)[1]; float len1 = Loon.Utils.MathUtils.Sqrt((dx1 * dx1) + (dy1 * dy1)); float len2 = Loon.Utils.MathUtils.Sqrt((dx2 * dx2) + (dy2 * dy2)); dx1 /= len1; dy1 /= len1; dx2 /= len2; dy2 /= len2; if ((dx1 != dx2) || (dy1 != dy2)) { result.AddPoint(GetPoint(i)[0], GetPoint(i)[1]); } } return result; }
public PBody AddPolygon(bool fix, Polygon p, float angle, float density) { PBody body = Polygon(fix, p, angle, density); world.AddBody(body); return body; }
public PBody AddPolygon(bool fix, Polygon p) { return AddPolygon(fix, p, 0F, 1F); }
public PBody Polygon(bool fix, Polygon p, float angle, float density) { PPolygon tmp = p.GetPPolygon(this.scale); PConcavePolygonShape shape = new PConcavePolygonShape(tmp.xs, tmp.ys, density); PBody body = new PBody(angle, fix, new PShape[] { shape }); return body; }
/// <summary> /// 将指定的Point集合注入Polygon当中 /// </summary> /// /// <param name="points"></param> /// <returns></returns> private static Polygon MakePolygon(List<Point[]> points) { Polygon polygon = null; if (!(points.Count==0)) { int size = points.Count; polygon = new Polygon(); for (int i = 0; i < size; i++) { Point p = (points[i])[0]; polygon.AddPoint(p.x, p.y); } for (int i_0 = size - 1; i_0 >= 0; i_0--) { Point p_1 = (points[i_0])[1]; polygon.AddPoint(p_1.x, p_1.y); } } return polygon; }