# Uneven spiraling around mesh

Hello everyone!

I’m trying to create a spiral polyline wrapped around a rather intricate mesh surface.

I was able to achieve something like this (screenshot)

However, the spirals are straight for an entire lap around the mesh before “jumping up” to the next level so-to-speak. What I’m after is more of a smooth spiral following the mesh surface all the way from the bottom to the top.

Also, I would like the spirals to be unevenly distributed around the mesh. So that if I have a shape that is taller in one end (like the mesh in the screenshot above), there will be more distance between the spiraling lines in that end (see illustration). But how to achieve that?

Any help is greatly appreciated!!!

All the best,
Nibbla

1. Get a BBox on the Mesh and create a mid box axis.

In C#:

Point3d p = box.GetCorners();
Point3d low = (p[0]+ p[1]+p[2]+p[3])/4.0;
Point3d high = (p[4]+ p[5]+p[6]+p[7])/4.0;
Line axis = new Line(low, high);

1. Make a spiral using this axis. Or make a “bending” spiral using a rail nurbs “based” on that axis (that’s tricky: for defining the “based” part of the story).

in C# (case rail):

1. From each spiralPt get the closest to the axis (or nurbs) and define a line.
2. Compute the ccx (Mesh/Line): that’s the tricky part: If their count >1 … sort the ccx pts with respect their distance to the spiralPt and get the first. This solves multi ccx events that are due to some possible “folding” Mesh areas.

In C#:

pts = pts.OrderBy(x=>x.DistanceTo(spiralPt)).ToList();

1. Connect all the ccx pts found (or do some steps more if you want each segment to belong to some face).

If you speak C# I could provide an indicative demo on all the above,

For more freaky stuff you can use a spherical spiral (using the center for your lines).

Or portions of some spherical spiral:

Thanks!

I’m in no means fluent in C#, but I know a little. Probably a lot less than you though

I was able to achieve something by intersecting several planes made with pufferfish (to achieve increasingly angled spirals) with the mesh. But the definition seems to work only when the “Number of Revolutions” and the “Resolution” of the intersections evens up in some odd way. If someone could take a look at the definition and explain to me why it works only in some cases (most often when the resolution is quite low it seems) i’d be very thankful!!!

Angled spiral around mesh.gh (732.2 KB)

All the best,
Nibbla

Here comes the pain (but no pain no gain).

“Forgot” to mention that this is unsolvable without a Physics Engine (but Daniel did the K2 thing [He forgot to provide any SDK … but nobody’s perfect]).

Morph_Flow_EntryLevel_V1.gh (151.4 KB)

So get (Note: N3 requires Kangaroo K2 [242 and up]):

1. An indicative way to apply Flow Morph on some helix (To do: do a helix C#) using some bending Curve (To do: you know what).
2. The best way to cut the mustard prior 3.
3. The best way to cut the mustard … er … after 2.

I hear you: that’s paranoid, has paranoid options plus is complex and ultra sensitive to parameter values > what’s this freaky nonsense anyway? Well … that’s Physics Engine … where anything is possible (and/or impossible [Karma: a must]).

Moral: life sucks.

1 Like

BTW: The big thing here is NOT the spiral (any spiral) … but what K2 can do on these ccx pts (while they are staying on the mesh). That said if you want to deal with folding mesh areas … then the Ray3d Method used here is not the proper way since IF it returns t >=0 (Point3d ccxPt = ray.PointAt(t)) … then we are talking about the first/closest pt (to ray’s fromPt) … but that’s trivial to manage via other ccx Methods. But is fast AND the face indices involved is a handy way to do something with them (if this is the final goal).

PS: Forgot to internalize the demo data, use this recycle the other:

Morph_Flow_EntryLevel_V1A.gh (159.6 KB)

Thank you! It is an interesting approach to the problem.

Added a few lines more providing an indicative result on the mesh faces related with hits.

Morph_Flow_EntryLevel_V1B.gh (162.1 KB)

NOTE: Mesh is auto triangulated. If you have quads and you want to work with them then you must sort the face indices/vertices (for obvious reasons). One way to do that is the classic MTV.SortEdges(MTVIndex) (plus some basic Lists ops taking into account MTV connectivity). The other (way simpler) is to sort by angle with regard the XAxis of a facePlane (faceCenter, faceNormal).

Kinda:

faceVertices = faceVertices.OrderBy(x=>Vector3d.VectorAngle(facePlane.XAxis, faceCenter-x)).ToList();

It could be a good entry level C# task to try to do the SortEdges thingy:

WHAT an idiot: should be

faceVertices = faceVertices.OrderBy(x=>Vector3d.VectorAngle(facePlane.XAxis, x-faceCenter, facePlane)).ToList();