2015. január 29., csütörtök

"EARLISH" DETERMINATION THAT THE POINT IS INSIDE THE DOMAIN OF THE TRIANGLE OR NOT.

"EARLISH" DETERMINATION THAT THE POINT
IS INSIDE THE DOMAIN OF THE TRIANGLE OR NOT.

To check that T is actually in triangle P1,P2,P3 we need totest the α,ß,Γ angles individually. And if any of the angle is bigger than 180.0 then the point is outside of the domain.To calculate these angles make 3 vectors out of the triangle points and T.

vec1 = normalize( P1-T)
vec2 = normalize( P2-T)
vec3 = normalize( P3-T)

Then the angles:
α = acos (dot vec1 vec2)
ß = acos (dot vec1 vec3)
Γ = acos (dot vec3 vec2)

if α>180.0 or ß>180.0 or Γ>180.0 then the point is outside of the triangle's domain. Well if any of the angle is 180.0 degree exactly then it is on the circumference of the triangle.

Now  you got to watch out that the dumb acos cannot do more than 180.0 so if any of those 2 is equals to the third than it is likely that you have the smaller side so you have to 360-value to get the real, also if you add the angles together and it is not 360.0 you can be sure that acos did cheat on one of them and it does lies outside of a triangle!





Nincsenek megjegyzések:

Megjegyzés küldése