Search code examples
mathopenglalgebra

Finding vectors


Given a vector V = (x, y, z), how do i find 2 vector that make up an axis with V ? In other words, one of them is perpendicular and lies in the same plane, and the other is normal to those two vectors.

I need this to implement a nice camera manager in OpenGL.


Solution

  • Given only one vector you can find and infinite number of vectors being perpendicular to it. In particular this set of vectors forms a plane to which your given vector is normal to.

    Given some vector not colinear with the first one, you can find a perpendicular (=orthogonal) vector by applying Gram-Schmidt orthogonalization. Let your first vector be ↑v, and ↑u is some vector so that ↑u =/= l ↑v, then a perpendicularized ↑u_ = ↑u - ↑v ( ↑u · ↑v)