Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / 3d angle math of doom

Author
Message
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 13th Jan 2012 00:14
Im dealing in vertices. I want to check which hemisphere a point is in compared to a 3d angle of a vertice.
I want to make sure the point is on the oposite side of the face.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 13th Jan 2012 00:30
What are you trying to accomplish?

The fastest code is the code never written.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 13th Jan 2012 01:06
You want to make sure two points are on opposite sides of a triangle right? I think you can just do this with dot product and cross product.

You have P1 P2 and P3 defining the triangle, and you have a point A. Consider P1 the origin, so now we have a triangle defined by (0,0,0), P2-P1 and P3-P1, with point A-P1.

The cross product will get a vector perpendicular to the surface of the triangle, that is: (P2-P1)x(P3-P1). To find where A-P1 lies along this line, take the dot product:
((P2-P1)x(P3-P1)).(A-P1)
To find out where another point B lies along this line, calculate the dot product again:
((P2-P1)x(P3-P1)).(B-P1)
If these two values have opposite signs, they lie on different sides of the triangle.


For two vectors, the dot product is defined by:

(Ax,Ay,Az).(Bx,By,Bz)=Ax*Bx+Ay*By+Az*Bz (a scalar value)

and cross product:
(Ax,Ay,Az)x(Bx,By,Bz)=(AyBz-ByAz,AzBx-BzAx,AxBy-BxAy) (a vector value)

Login to post a reply

Server time is: 2024-03-28 20:18:52
Your offset time is: 2024-03-28 20:18:52