Jump to content
  • Advertisement
Sign in to follow this  
m@

plane vectors from two points

This topic is 3976 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

If I subtract two points to acquire a direction vector for use in a plane I get strange results when projecting, like (2,3.0) - (-5,7,8). I figured out that by only using the second point or direction as such that the plane projection would work, for example direction - 0,0,0(origin) which isn't really subtracting anything. It makes some sense but I don't understand fully.... and would like. I have ended up doing the projection then displacing it to the location I require it... I hope this made sense. Thanks in advance. -M@

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure whether I understand your problem, so please be patient with my answer.

Projecting a direction vector onto a plane just yields in another direction vector. Since direction vectors have no start or end but a direction and length only, you could not expect it to occur at any _position_.

The correspondence is as follows: The difference of 2 position vectors yields in a direction vector (as you've stated correctly). Projecting the both points onto a plane and computing the difference of the projected points yields in the same direction vector as projecting the original difference vector onto that plane.

Projecting a point V onto a plane P
P := { O n }
where O denotes any point on the plane (e.g. its "origin") and n the plane's normal (orthogonal and of unit length), one would do
VP := V - n * ( n . ( V - O ) )
what actually computes the shortest difference vector from the plane to V and subtracts that from V. That means
  a position = a position - a direction * a scalar
where
  a scalar = a direction . a direction
so all is okay.

EDIT:
If, on the other hand, you are computing a difference vector d first and want to project that, you have to go a slightly other way:
dP := d - n * ( n . d )
what means
  a direction = a direction - a direction
what is also okay.

The difference of these two ways if looking at the formulas (e.g. assuming you are using a vector implementation that doesn't distinguish between positions and directions) is in the right term of the dot-product. Perhaps that is the pitfall you're trapped in?

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!