23rd May 2006

signed angle between two vectors(3d) in c/c++

posted in reviews |

I tried to realize some point-in-polygon-test in 3D for my raytracer and came upon the problem to calculate a signed angle between 2 vectors. Trying to find this in the web was not easy, somehow most people project the polygon plane and the point into 2d and do the test there. But here is the method i found:

signed_angle = atan2(  N * ( V1 x V2 ), V1 * V2  );
// where * is dot product and x is cross product
// N is the normal to the polygon
// ALL vectors: N, V1, V2 must be normalized

It worked for me.

This entry was posted on Tuesday, May 23rd, 2006 at 11:58 pm and is filed under reviews. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There are currently 3 responses to “signed angle between two vectors(3d) in c/c++”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On January 20th, 2009, Polypterus said: [Quote]

    Thanks man! You just fixed my chase camera!!

  2. 2 On June 8th, 2009, paul said: [Quote]

    Very cool!!!!!
    thanx Man!!!!!!!

  3. 3 On January 4th, 2012, Best Appetite Suppressant said: [Quote]

    The Paleo Diet…

    […]in the following are several url links to web pages I always link to seeing as we think they’re worth browsing[…]…

Leave a Reply