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.

+3


source to share


2 answers


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.

+3


source


let V = Y + aZ Z dot V = 0 so that you can solve a and get V Now use V and Z as base



You may need to normalize vectors and use double type to get the precision you want.

0


source







All Articles