Can someone please explain the rationale behind the ‘plane flipping’ phenomenon show here? I’m sure there is a good reason for this behaviour, I’d just like to be able to predict it happening in the future.

A Curve Frame tries to align to the tangent vector (unambiguous) and the curvature vector (ambiguous for a line which has no curvature.) Therefore you will not get consistent results for straight lines. If you want a consistent frame, you should construct one yourself given the tangent vector and some other vector (for instance, if you want a plane that stays as close to XY-parallel as possible, use the tangent as the first vector, and the cross product of the Z axis and the tangent as the second vector.)

Also, just to complement a little here, it really just depends what kind of orientation you are looking for. Remember that planes are just data about orientation in Cartesian space.

You can construct them in different ways, and you also have to consider 2 important things:

The direction of the curve matters

The order in which you compute the Cross product matters, because it does not obey the commutative law.

Those two points complement each other because if you first compute the Cross product that has a tangent with one direction and then do it again but with a reversed tangent ( aka, your curve is flipped) you will get a plane with a different orientation.

Just to illustrate a little, and the drawing convention:

Green vectors where used to compute the third vector shown in red

Here the plane is created by calculating the Dot product between the vector with origin at 0,0,0 ending at the point with the curves tangent, given rise to the third vector shown in red. So here you have a plane with a totally different orientation.

This plane is how Andrew was suggesting you to calculate it. The Cross product between a unit Z vector and the tangent, which gives the third vector, in red, which its also the planes Y-Axis

And finally, this plane. Which in Grasshopper language its a plane perpendicular to a vector. Which basically is the Cross product between the tangent and the Unit Z vector and then the Cross product of that result with the tangent once again.

Thanks very much for the further explanation. I have wired up the desired script in GH for what I’m trying to achieve, but am not sure how I would recreate this with a C# script.

Learning never stops… its $%£# endless lol There is always things to learn and areas to improve in. I wouldn’t worry to much about LINQ, I think that training ones self in computational geometry, mathematics and algorithms is much much more important. There is where the real stuff takes place. Of course, learning proper programming fundamentals is then key to be able to deploy succesfull code. So those are the 2 weights on both sides of the scale.