private static List <PointList> BridgeRectangleToRoundRectangle(PointList rect, PointList roundRect) { int pointsPerCorner = roundRect.Count / 4; List <PointList> list = new List <PointList> (); // Corner 1 for (int i = 1; i < pointsPerCorner; i++) { PointList points = new PointList(); points.Copy(rect, 0); points.Copy(roundRect, i); points.Copy(roundRect, i - 1); list.Add(points); } // Corner 2 for (int i = 1; i < pointsPerCorner; i++) { PointList points = new PointList(); points.Copy(rect, 1); points.Copy(roundRect, pointsPerCorner + i); points.Copy(roundRect, pointsPerCorner + i - 1); list.Add(points); } // Corner 3 for (int i = 1; i < pointsPerCorner; i++) { PointList points = new PointList(); points.Copy(rect, 2); points.Copy(roundRect, 2 * pointsPerCorner + i); points.Copy(roundRect, 2 * pointsPerCorner + i - 1); list.Add(points); } // Corner 4 for (int i = 1; i < pointsPerCorner; i++) { PointList points = new PointList(); points.Copy(rect, 3); points.Copy(roundRect, 3 * pointsPerCorner + i); points.Copy(roundRect, 3 * pointsPerCorner + i - 1); list.Add(points); } // Sides for (int i = 1; i <= 4; i++) { PointList points = new PointList(); points.Copy(rect, i % 4); points.Copy(roundRect, (i * pointsPerCorner) % roundRect.Count); points.Copy(roundRect, (i * pointsPerCorner - 1) % roundRect.Count); points.Copy(rect, (i - 1) % 4); list.Add(points); } return(list); }
// // Reverse // public PointList Reverse() { PointList result = new PointList(); for (int i = this.Count - 1; i >= 0; i--) { result.Copy(this, i); } return(result); }
// // Shift // public PointList Shift(int shift = 1) { PointList result = new PointList(); for (int i = 0; i < this.Count; i++) { int index = (i + shift) % this.Count; result.Copy(this, index); } return(result); }
public List <PointList> Bridge(PointList pointsB, BridgeMode mode = BridgeMode.Open) { List <PointList> list = new List <PointList> (); if (Count != pointsB.Count) { Debug.LogError("PointList : Cannot Bridge PointLists of different size (" + Count + " / " + pointsB.Count + ")"); } else { // Add top points int iMax = this.Count - 1; if (mode == BridgeMode.CloseReuse) { iMax++; } for (int i = 0; i < iMax; i++) { // Add side points PointList points = new PointList(); points.Copy(this, i); points.Copy(this, (i + 1) % this.Count); points.Copy(pointsB, (i + 1) % this.Count); points.Copy(pointsB, i); list.Add(points); } if (mode == BridgeMode.CloseDuplicate) { PointList points = new PointList(); points.Copy(this, iMax); points.Add(this [0]); points.Add(pointsB [0]); points.Copy(pointsB, iMax); list.Add(points); } } return(list); }
public void TestCopy() { PointList list0 = new PointList(); list0.Add(1f, 1f, 1f); int uid0 = list0.Uid(0); PointList list1 = new PointList(); list1.Copy(list0, 0); Assert.AreEqual(uid0, list1.Uid(0)); }