Projecting a vector on a plane.
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
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
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
2 vectors cant make a plane but the projection of the vector v1 onto the line v2-v3 is given by
Vector a=v1-v2;
Vector b=v3-v2;
float t = dot(a, b)/dot(b, b);
Vector projection = v2 + t * b;
Vector a=v1-v2;
Vector b=v3-v2;
float t = dot(a, b)/dot(b, b);
Vector projection = v2 + t * b;
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
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
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.
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.
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
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
And i will search for a homepage which translates maths terms from german to english ;)
Thanks again.
Thanks again.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement