Gram-Schmidt Process Calculator
Convert vectors to an Orthogonal or Orthonormal Basis.
Input Basis { v1, v2 }
Orthogonal Basis { u1, u2 }
Perpendicular, but not length 1.
Orthonormal Basis { e1, e2 }
Perpendicular AND length 1.
Process Visualization
What is the Gram-Schmidt Process?
The Gram-Schmidt process is an algorithm to take a set of “messy” vectors (linearly independent but pointing in random directions) and turn them into a “clean” set of vectors that are all perpendicular to each other (Orthogonal) and have length 1 (Orthonormal).
The “Shadow” Concept
Imagine Vector v2 casting a shadow onto Vector v1. This shadow represents the part of v2 that is “parallel” to v1.
To get a perpendicular vector, we simply subtract the shadow. What remains is the part of v2 that points purely 90 degrees away from v1.
Why Orthonormal?
Orthonormal bases (like the standard x and y axes) make math incredibly easy.
- Dot products become simple.
- Finding coordinates is just projection.
- Matrices become rotations (preserve length).
Algorithm Steps (2D)
- Keep the first vector: Set u1 = v1.
- Project & Subtract: Find the projection of v2 onto u1. Subtract it from v2. This gives u2.
u2 = v2 – proj(v2 on u1) - Normalize (Optional): Divide u1 and u2 by their lengths to get e1 and e2.
Frequently Asked Questions (FAQ)
Q: Does the order matter?
A: Yes! The first vector u1 will point in the same direction as the first input v1. The subsequent vectors will adjust to be perpendicular to the previous ones. Changing the order changes the final basis vectors (though they still span the same space).
Q: What if the vectors are already parallel?
A: Then they are “Linearly Dependent”. The subtraction step will result in the Zero Vector (0,0), because the vector is entirely “shadow”. You cannot form a basis from dependent vectors.
Q: Is this used in computer graphics?
A: All the time! It’s used to create camera coordinate systems. If you know where the camera is looking (Forward vector) and roughly where “Up” is, Gram-Schmidt perfects the “Up” vector to be truly perpendicular to “Forward”.