How do I create an orthogonal basis based on two nearly perpendicular vectors?
I am trying to create an orthogonal coordinate system based on two "nearly" perpendicular vectors that are derived from medical images. I have two vectors, for example:
Z=[-1.02,1.53,-1.63];
Y=[2.39,-1.39,-2.8];
which are almost perpendicular since their dot product is 5e-4.
Then I find their cross-work to create my third base:
X=cross(Y,Z);
Even this third vector is not completely orthogonal Z
and Y
since their inner products are in the order of -15 and -16, but I think it is almost zero. In order to use this set of vectors as my orthogonal basis for the local coordinate system, I assume they must be almost completely perpendicular. At first I thought I could do this by rounding my vectors to less than decimal digits, but didn't help. I think I need to find a way to slightly change the original vectors to make them more perpendicular, but I don't know how.
Any suggestions would be appreciated.
source to share
Gram-Schmidt is correct as stated above.
Basically, you want to subtract the Y component that is in the Z direction from Y (Note: you can alternatively work on Z instead of Y).
The Y component in the Z direction is specified as follows:
dot(Y,Z)*Z/(norm(Z)^2)
(projection of Y to Z)
Note that if Y is orthogonal to Z, then this is 0.
So:
Y = Y - dot(Y,Z)*Z/(norm(Z)^2)
and Z remains unchanged.
source to share