Skip to content

Commit

Permalink
utility bits
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed Apr 24, 2018
1 parent 01f5ed4 commit 89dcd9f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
37 changes: 37 additions & 0 deletions curve/PolyLine2d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}



}


Expand Down
6 changes: 3 additions & 3 deletions mesh/MeshEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ public virtual int[] StitchUnorderedEdges(List<Index2i> EdgePairs, int group_id
/// vertex ordering must reslut in appropriate orientation (which is...??)
/// [TODO] check and fail on bad orientation
/// </summary>
public virtual int[] StitchSpan(int[] vspan1, int[] vspan2, int group_id = -1)
public virtual int[] StitchSpan(IList<int> vspan1, IList<int> 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--;

Expand Down

0 comments on commit 89dcd9f

Please sign in to comment.