public static List <Vector3i> SegmentList(Vector3 center, Vector3 dir, int start, int len) { IntLine l = new IntLine(center, dir); List <Vector3i> segment = new List <Vector3i>(); for (int k = 0; k < len; k++) { segment.Add(l.Get(k)); } return(segment); }
public static IEnumerable <Vector3i> Segment(Vector3 center, Vector3 dir, int start, int len) { IEnumerable <int> range = Enumerable.Range(0, Math.Abs(len)); if (len < 0) { range = range.Select(x => - x); } IntLine l = new IntLine(center, dir); return(range.Select(x => l.Get(start + x))); }
public static IEnumerable <Vector3i> Segment(Vector3 from, Vector3 to) { IntLine l = new IntLine(from, (from - to)); int start = 0; int len = l.IndexOf(to); Printer.Log(10, "Segment", start, len); IEnumerable <int> range = Enumerable.Range(0, Math.Abs(len)); if (len < 0) { range = range.Select(x => - x); } return(range.Select(x => l.Get(start + x))); }
public static void _Main(string[] args) { Vector3 c = new Vector3(); c[1] = 1.0f; Vector3 d = new Vector3(); d[0] = 2.0f; d[2] = 0.5f; IntLine l; if (true) { l = new IntLine(c, d); Console.WriteLine("-"); foreach (int k in Enumerable.Range(-5, 10)) { Console.WriteLine(String.Format("{0} -> {1}", k, l.Get(k))); } l = new IntLine(c, d * 0.01f); // Does not depend on dir scaling Console.WriteLine("-"); foreach (int k in Enumerable.Range(-5, 10)) { Console.WriteLine(String.Format("{0} -> {1}", k, l.Get(k))); } } Console.WriteLine("-"); foreach (Vector3i v in IntLine.Segment(c, d, 2, 5)) { Console.WriteLine(String.Format("{0}", v)); } Console.WriteLine("-"); foreach (Vector3i v in IntLine.Segment(c, d, 2, -5)) { Console.WriteLine(String.Format("{0}", v)); } Console.WriteLine("-"); foreach (Vector3i v in IntLine.Segment(c * 10f, d * 10f)) { Console.WriteLine(String.Format("{0}", v)); } }