Criteria to choose between clockwise and anticlockwise rotation of lines

Hi guys, I come to seek some knowledge.

I have a couple of lines pointing towards a center, and I need to rotate them so that they face the white direction. This rotation must be according to the least rotation possible.

I was not able to think of an appropriate criteria to use. I thought about comparing Angle and Reflex angle, but it is not enough: In the picture you can see that both reflex angles (blue) are larger than the actual angle (red), but the line in the upper corner needs to be rotated anti-clockwise while the line in the lower corner needs to be rotated clockwise.

The final result should look like this: (16.3 KB)

Hi @ShynnSup,

You can use plane alignment to get the minimal rotation angles!

Rotation (11.1 KB)

2 Likes (10.4 KB)

1 Like

You can create new curves with Line SDL (20.2 KB)


Thank you all guys!

@anon39580149 I am afraid I need the angle for further operations, my fault for not explaining in OP.

@Joseph_Oster I am surprised by the fact that Angle does not take for default XY plane. Good to know!

@diff-arch Smart!

Ok try this


Hi @diff-arch any idea why Plane Align does not actually return the smallest angle? In this case, item nr 7, it makes sense to rotate anti-clowise 81.87, but Plane Align rotates clockwise 261.87.

This represents a problem for me, because the goal is to plug a slider into rotation angle, going from 0 to 180 and having all lines progressively line up with the main direction. The problem is, some lines make unnecessary additional rotations:

You can see clearly how some lines make the long rotation instead of the short one (13.3 KB)

Me too. (15.0 KB)

I’m not exactly sure myself, but I would guess that this has to do with the line directions of the starting curves, and the Align (Align Planes) having to make a decision in some fringe cases, whether to use the measured angle or reflex.

OK, so you could use the following strategy:

For measured angles below 0.0 and above Pi (i.e. 180°), the negative reflex angles are now used, since they represent the minimum rotation angles in the given plane.

Instead of subtracting the angles from 2 Pi (i.e. 360°), which might return undesired results, simply drive the rotation animation with your values from 0 to 180 that get remapped to the rotation angles.

Rotation (15.6 KB)

1 Like

Beautiful. That was a little more complex than expected. I find it quite counter intuitive to work with angles in GH.

1 Like

I don’t understand what you want exactly

a (1).gh (10.8 KB)


I think that is correct too! Thank you!

1 Like