rich_lord Posted July 27, 2017 Share Posted July 27, 2017 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. Quote Link to comment Share on other sites More sharing options...
Juraj Posted July 27, 2017 Share Posted July 27, 2017 Hi, 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 2 Quote Link to comment Share on other sites More sharing options...
rich_lord Posted July 27, 2017 Author Share Posted July 27, 2017 Thanks Juraj! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.