Getting positive and negative angles between two vectors

   7338   2   1
User Avatar
Member
245 posts
Joined: Sept. 2011
Offline
I have two vectors, a red one and a blue one as you can see in my screenshot.

When I use a dot product and arc cosine I am getting the angles, but they're all positive values. In the image you can obviously see the red normal is sometimes on the left side and sometimes on the right side of the blue normal (which is correct in my case).

My final goal is I want to check when corners are convex and when they are concave. So by checking the angles concave should be -45 degrees and concave should be 45 degrees, but all I get is the difference between the two vectors (which is always 45 degrees).

Am I missing something?

Attachments:
Capture.PNG (423.0 KB)

User Avatar
Member
1907 posts
Joined: Nov. 2006
Offline
You should be able to figure out which way the line is “turning” by taking the cross product of your blue and red vectors and then comparing that vector to your green one with another dot product. You can then use that value to determine if your angle should be negative.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
245 posts
Joined: Sept. 2011
Offline
Thanks this is working, I wasnt aware that the vectors pointing downwards and upwards actually meant something.

Do you also happen to know why/how this is happening? I would like to understand what Houdini actually is doing to get this result.

By the way; I used the cross product between forward and backward curve direction instead, because these were already calculated and basically the same result.
  • Quick Links