Jump to content
  • Advertisement
Sign in to follow this  
u235

where a point is in relation to another point

This topic is 3888 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know how to find the distance between two 3D points, but I was wondering if there is a way to tell if point A is behind or in front another point, B, given a normal vector for point B, or in the case of a camera's position, it's look at vector? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Find the vector from A to B. Take the dot product of that vector with the orientation of the camera. The sign will tell you if A is in front of B or vice versa.

Share this post


Link to post
Share on other sites
Thanks. For clarification, I am assuming that a negative sign means behind and positive is in front? Also, do the vectors need to be normalized prior to taking the dot product?

Share this post


Link to post
Share on other sites
Ok, all that makes sense and all, but I am having a bit of trouble finding the vector from camera position to the point in question. I found this formula that almost makes sense except for one thing. Here's the formula:

v = (xb-xa)i + (yb-ya)j + (zb-za)k

The i, j and k have carets over them, meaning they are unit vectors. I'm not exactly sure what they are though. The page I got this from doesn't explain what they are. My initial assumption is that they are the unit vectors of each respective axis, which makes sense, but I just want to make sure. Thanks.

Share this post


Link to post
Share on other sites
Ok, let's say you have points A and B. Where A is (xA, yA, zA) and B is (xB, yB, zB). The vector from A to B is the vector that when added to (xA, yA, zA) equals (xB, yB, zB). So let's say the vector is (xV, yV, zV). Then you'd have

xA + xV = xB
yA + yV = yB
zA + zV = zB

xV = xB - xA
yV = yB - yA
zV = zB - zA

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!