Hello everyone,
I am using the Angle node to get radians between two vectors. Later I convert them to Degrees, but I only get Positive(+) degrees. I need both Positive (+) and Negative (-) degrees to move ahead. I am attaching my grasshopper file below.
The Angle node in RhinoCommon returns the angle between two vectors in radians, and this value is always positive. If you want to get a signed angle in degrees (i.e. an angle that can be positive or negative), you can use the following approach:
The Vector3d.VectorProduct(vec1, vec2) calculates the vector product of the two vectors, which has the direction of the angle of rotation. The Z component is positive for counter-clockwise rotations, and negative for clockwise rotations. So, by multiplying the angle in degrees by the Z component of the cross product, you will get the angle in degrees, with a positive or negative value depending on the rotation direction of the angle.
Alternatively, you could also use the Vector3d.UnsignedAngle method, and then use Math.Sign method of the Math class to get the sign of the angle and multiply it by the angle obtained from the UnsignedAngle Method.
You need to provide a plane (World XZ) so that the component calculates an oriented angle, otherwise it just takes the absolute value. See more ideas in this thread !
I like the cross/dot product approach also, it’s doable with components.