Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Vector projection to a local base Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
takis

April 05, 2005, 09:50 AM


Two points: A and B

local coordinatesystem:
lz
lx
ly
origin A

The projection of a the vector B-A into local base, is that the same as:
x=dot(lx, B-A-A);
y=dot(ly,B-A-A);
z=dot(lz, B-A-A);

 
Reedbeta

April 05, 2005, 01:15 PM

It's B - A, not (B - A - A)

This is true only if Lx, Ly, Lz form an orthonormal basis.

 
Bramz

April 05, 2005, 01:28 PM

reedbeta is right.

if lx, ly, lz isn't orthornormal, you can still use the dot products, but you'll have to use reciprocal base vectors for it. Or something like that, i'm not sure if that are the correct words. It could be something with covariant and contravariant as well.

Anyway, it's somewhat explained in here: http://www.flipcode.com/articles/gprimer2_issue03.shtml

IIRC in 3D it boils down to: rx = cross(ly, lz) / V, ry = cross(lz, lx) / V and rz = cross(lx, ly) / V with V = dot(lx, cross(ly, lz))

then

x=dot(rx, B-A);
y=dot(ry,B-A);
z=dot(rz, B-A);

notice that if lx, ly and lz is orthonormal, rx == lx, ...

Bramz

 
Reedbeta

April 05, 2005, 05:10 PM

In general, if you have a non-orthonormal basis you have to either use Gram-Schmidt to convert it into an orthonormal basis or you have to use some form of Gauss-Jordan elimination (since figuring out the coordinates of a vector w.r.t a certain basis is essentially solving a linear system).

 
Bramz

April 06, 2005, 10:15 AM



Reedbeta wrote: ... or you have to use some form of Gauss-Jordan elimination ...


Which is exactly what I'm doing with those reciprocal vectors, though I'm actually using Cramer to solve the system. Thanks, I realized I was doing exactly that.

Greetz,
Bramz

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.