Jump to content
guache

Signed angle between vectors in VEX

Recommended Posts

In Vex, I'm trying to find a signed angle between two vectors i.e. an angle which treats one vector as a "base" and the other as a rotating "clock hand", so that I get positive angle for a concave angle between the two (0-180 deg) and a negative angle for a convex angle between the two (180-360 deg). The dot product on normalized vectors gives me the angle, but it's symmetric. Is there a trick that gets me the sign?

Edited by guache

Share this post


Link to post
Share on other sites

If v is your base, and w the clock hand, and n is a reference vector perpendicular to both (this is necessary if you want an angle in 0-360), then the angle is given as

atan2(dot(cross(n,v), w), dot(v,w));

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×