Jump to content
  • Advertisement
Sign in to follow this  
Kande

Projecting a vector on a plane.

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

Hi, i have a vector V1 and a plane that is described by two vectors V2 and V3. Now i want the vector that represents the projection of V1 on the plane that is descibed by the two vectors V2 and V3. I know that this is not that hard but somehow i dont get the clue :( Thanks in advance Kande

Share this post


Link to post
Share on other sites
Advertisement
you need to be more specific. What V2,V3 is? point on plane and plane normal? 2 vectors so plane contains origin and V2,V3 (i.e. plane of triangle 0,P2,P3) ?
By project you mean find point(3D) on the plane that is closest to V1 ? Or 2D coordinates "on plane" ? there's more than one possible meaning.

If you have point on plane P=V2 and normal of plane N=V3 to project onto plane you need V_proj=V1+((P-V1)dot N)*N

Share this post


Link to post
Share on other sites
You need the plane normal, which you calculate using the cross product, i.e.

vector n = Cross(v2, v3); // order of v2, v3 doesn't matter in this case

Normalise this

n = n / n.length(); //generates a divide by zero error if e.g. v2 and v3 parallel

Than the answer is

vector v1_projected = v1 - Dot(v1, n) * n;

Dot is the dot product, so the * does a "scalar * vector" product

Share this post


Link to post
Share on other sites
Yes..... unfortunately the german language uses completly different terms for everything in maths than the rest of the world does... sorry if i am not specific enough or just use the wrong terms, lets say V1 is (1,1,1) and V2 is (1,0,0) and V2 is (0,1,0). The origin of them is (0,0,0). Then the plane is every point in space that has a 0 z component. V1(1,1,1) projected onto this plane will be (1,1,0). Thats easy. But how do i get the vector from other planes that are not just the planes between the coordinate systems axis. Hope thats clearer.

Share this post


Link to post
Share on other sites
as I understood, you are talking about plane that contains origin (0,0,0) and V2 and V3 . so go with Johnb's solution. Idea is to first compute normal of plane, second "move" the point along normal so it is on the plane.

Share this post


Link to post
Share on other sites
The method I described should work. E.g. with the examples you gave.

V2 = vector(1, 0, 0);
v3 = vector(0, 1, 0);

n = Cross(v2, v3); // gives n = (0, 0, 1)

// n.length() = 1
// therfore

n = n / n.length(); // gives n = (0, 0, 1)

// Dot(v1, n) is 1
// therfore

vector v1_projected = v1 - Dot(v1, n) * n;
= (1, 1, 1) - 1 * (0, 0, 1)
= (1, 1, 0)

The 'cross product' is also called the 'vector product' and the 'outer product'.
The 'dot product' is also called the 'scalar product' and the 'inner product'

the vector 'length' is just it's size

Share this post


Link to post
Share on other sites
And i will search for a homepage which translates maths terms from german to english ;)
Thanks again.

Share this post


Link to post
Share on other sites
Wikipedia says the German for Cross and Dot product are

Cross product: Kreuzprodukt/Vektorprodukt/vektorielles Produkt/äußeres Produkt
Dot product: Skalarprodukt/inneren Produkt

http://de.wikipedia.org/wiki/Kreuzprodukt
http://de.wikipedia.org/wiki/Skalarprodukt

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!