diff --git a/curve/PolyLine2d.cs b/curve/PolyLine2d.cs index 5ff1aac5..a0d201e5 100644 --- a/curve/PolyLine2d.cs +++ b/curve/PolyLine2d.cs @@ -340,6 +340,43 @@ public PolyLine2d Transform(ITransform2 xform) } + + static public PolyLine2d MakeBoxSpiral(Vector2d center, double len, double spacing) + { + double d = spacing / 2; + PolyLine2d pline = new PolyLine2d(); + pline.AppendVertex(center); + + Vector2d c = center; + c.x += spacing / 2; + pline.AppendVertex(c); + c.y += spacing; + pline.AppendVertex(c); + double accum = spacing / 2 + spacing; + + double w = spacing / 2; + double h = spacing; + + double sign = -1.0; + while (accum < len) { + w += spacing; + c.x += sign * w; + pline.AppendVertex(c); + accum += w; + + h += spacing; + c.y += sign * h; + pline.AppendVertex(c); + accum += h; + + sign *= -1.0; + } + + return pline; + } + + + } diff --git a/mesh/MeshEditor.cs b/mesh/MeshEditor.cs index 117d744b..8f201332 100644 --- a/mesh/MeshEditor.cs +++ b/mesh/MeshEditor.cs @@ -246,10 +246,10 @@ public virtual int[] StitchUnorderedEdges(List EdgePairs, int group_id /// vertex ordering must reslut in appropriate orientation (which is...??) /// [TODO] check and fail on bad orientation /// - public virtual int[] StitchSpan(int[] vspan1, int[] vspan2, int group_id = -1) + public virtual int[] StitchSpan(IList vspan1, IList vspan2, int group_id = -1) { - int N = vspan1.Length; - if (N != vspan2.Length) + int N = vspan1.Count; + if (N != vspan2.Count) throw new Exception("MeshEditor.StitchSpan: spans are not the same length!!"); N--;