Vector Angle

Is there anyway to force the Vector Compute Angle component to calculate angles in certain direction, like always clockwise. As it looks like it’s computing the smallest angle between vectors.

Vector Angle.gh (10.6 KB)

You’ll need to supply the optional plane input respectively…

1 Like

Thanks. That works.

Or…

2 Likes

I really wish there was an option to get the result as an oriented angle, considering the order in which the vectors are input and the trigonometric orientation : anti-clockwork is positive as with rotation angles in Rhino.

1 Like

to be honest this is a very interesting topic, but I can’t understand in which cases the angle would be negative

when a plane is supplied, the angle between vectors is measured on the projection of those vectors on that plane

when a plane is not supplied, Rhino calculates the best plane using the first vector as X-axis and the second as Y-axis, like this:

vector_angle.gh (18.4 KB)

I wasn’t 200% sure this was correct, but if I reverse the vectors and also disconnect the “measuring Plane”, the angle is always the same, so this leads me to think the plane I have drawn is the Plane that GH calculates internally if no Plane is supplied

and of course with this you can only get positive angles because of the method that very Plane is created (see the Z direction of the measuring plane that just flips in order to give you positive results when vector order is Reversed)

unless you are willing to supply some “external measuring references” (for instance one thing that comes to mind is the direction the Z axis of that measuring plane should prefer to face) I think there’s no trigonomic way to definitely solve this? maybe I’m missing a trivial point?

To do that the Atan2 function comes in handy:

I’ve also implemented it in the SignedVectorAngle component in my froGH plugin:

1 Like

you can use cross product’s sign (along with a plane mapping in some cases) to determine whether the angle is clockwise or counterclockwise - the sign should tell you if you should take the angle as is or add pi to it.

Thanks Inno, now I understand why, if no plane is given as input, the angle is independent of the order of the two vectors.
So, when I set a plane as input to the “Angle” component, the order matters, but the value is always positive.


240429_PROG_Darn vector angles.gh (25.0 KB)

I’d like the value to be restricted between -PI and PI because I want to create a domain mapping to restrain the orientation of the second vector to a certain “sector” within [-PI ; PI].
This is related to milling issues ; in particular, I don’t want my spindle to reach a point from “underneath” because there’s a table there !

Having at least the option on the component would spare me the work of restricting the values :

1 Like

Exactly what I need.
There seems to be lots of interesting components in your plug-in.
Thanks Alessio !

2 Likes

Yep, that’s another was to do it indeed.
Thanks Adel.

If whatever function you’re using returns angles from 0 to 2Pi, simply subtract Pi to get the angle in the desired interval

Nope PI/4 is 45° and PI/4-PI is -135°

Not sure what’s your reason for remapping, but if you want to simply remap any value from an interval [0, 2x] to [-x, x] the method is value-x. Try it in the remap component

If you have a different logic, for remapping, say

F(x) =
x when x <= pi
x - 2Pi when x> pi

Then that should be mostly doable in an expression component or a c#/py script

The “correctness” of the remapped value is a meaningless point to discuss outside the framework of the remapping.