We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Behind or in front of a 3d vector
Page Index Toggle Pages: 1
Behind or in front of a 3d vector (Read 1034 times)
Behind or in front of a 3d vector
Apr 23rd, 2010, 2:49am
 
Hi

I was hoping that someone here could tell me how to investigate if a point is behind or in front of a 3d vector. (Like questioning if a point is above or below a plane, but with only the normal vector known)


Re: Behind or in front of a 3d vector
Reply #1 - Apr 23rd, 2010, 7:45am
 
I'm not sure your question makes sense if interpreted literally as asked.  But if I "read into" your question a bit, and assume you mean that your vector is the normal of a plane equation where d == 0, then the sign of "normal dot point" will tell you which side of that plane the point is on.  Is that what you're asking?
Re: Behind or in front of a 3d vector
Reply #2 - Apr 24th, 2010, 6:16am
 
yes I think so. Thank you. And sorry for not making sense Smiley

But to be certain: Assuming for instance that my vector is part of a space ship element in a game, where this vector keeps track of the ships orientation in 3d. This could be called the orientation vector. If I want to know if something is in front of that ship, then I:
1. Create a new  vector from the ships position (a point) to the point in space I want to investigate
2. Calculate the dot product of the orientation vector and the new vector
3. Look at the sign of the dot product

Is that right?
Re: Behind or in front of a 3d vector
Reply #3 - Apr 24th, 2010, 7:53am
 
Yup, that's it. If it's >0 it's in front of the ship, <0 behind.
Page Index Toggle Pages: 1