AI Tutor
How do 3D video game engines know if a player's line of sight is at an exact right angle to a wall?
Instead of measuring angles with expensive trigonometry, graphics software uses a single multiplication trick: the scalar product.
To see why this test works, let's look at how the scalar product connects geometry to algebra.

The Perpendicularity Condition

The scalar product (or dot product) between two non-zero vectors a\mathbf{a} and b\mathbf{b} is defined geometrically as aβ‹…b=∣a∣∣b∣cos⁑θ\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}| |\mathbf{b}| \cos\theta, where ΞΈ\theta is the angle between them.
In the 1880s, American physicist Josiah Willard Gibbs developed this product to simplify complex electromagnetic equations into simple component algebra.
When two vectors are perpendicular (at an angle of θ=90∘\theta = 90^\circ), the cosine of the angle becomes cos⁑(90∘)=0\cos(90^\circ) = 0.
Because ∣aβˆ£β‰ 0|\mathbf{a}| \neq 0 and ∣bβˆ£β‰ 0|\mathbf{b}| \neq 0, the formula gives aβ‹…b=∣a∣∣b∣(0)=0\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}||\mathbf{b}|(0) = 0.
What happens when we compute this using coordinates in three dimensions?

Testing 3D Vectors

In component form, you calculate the scalar product by multiplying matching components and adding the results: aβ‹…b=axbx+ayby+azbz\mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y + a_z b_z.