signed angle between two vectors(3d) in c/c++
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.