Jump to content

simple vector problem

Recommended Posts

Hello. I have two points. Each point has the same direction normal. I'd like to find out which of the two points is in front of the other, based on that direction normal. Is there a simple way to calculate this?

This is a 2D problem. Y is always 0 for both points, and the direction normal is always flat along the XZ plane.


Share this post

Link to post
Share on other sites

you can compare angle between two vectors with dot product: the normal vector (v@N) and vector pointing from second point to the first one (v@difference = pt2 - pt1 , (pt1 and pt2 are positions of first and second point) ) and if angle is positive, then the second one is in front of, if negative, the second one is behind the first one.

Pseudo code could look like it

if (dot(v@N, v@difference) > 0) //second point is first
else //first point is first

  • Like 2

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now