3D Math Written by Deepseek AI on 06-30-2026

This page was generated by AI. It is not a source of trustworthy medical information.
The curated page (written by a real person) is here

Vectors: The Heartbeat of 3D Space

At the core of every 3D application lies the vector. A vector is a mathematical entity that has both magnitude and direction. In three-dimensional space, a vector is typically represented as (x, y, z). Vectors are essential for describing positions, velocities, and forces. For example, the point at (3, 0, 2) can be considered a position vector from the origin. Adding two vectors gives you a new direction, while subtracting them yields the displacement between points. The dot product and cross product are fundamental vector operations: the dot product measures alignment, and the cross product produces a vector perpendicular to the input pair.

Matrices: The Engines of Transformation

A matrix in 3D math is a rectangular array of numbers, often arranged in 4×4 form to handle both rotation and translation in a single operation (using homogeneous coordinates). When you multiply a vector by a matrix, you apply a linear transformation—such as scaling, rotating, or shearing. The identity matrix leaves a vector unchanged, while a rotation matrix rotates a point around an axis. The real power of matrices comes from their ability to chain multiple transforms: you can multiply several matrices together into a single “composite” matrix and then apply it to thousands of vertices efficiently.

// Example: 4x4 translation matrix (moves by tx, ty, tz) 1 0 0 tx 0 1 0 ty 0 0 1 tz 0 0 0 1

Quaternions: Smooth Rotations Without Gimbal Lock

While Euler angles (pitch, yaw, roll) are intuitive, they suffer from a problem called gimbal lock, where two axes align and you lose a degree of freedom. The solution is the quaternion. A quaternion is a four-dimensional number system: q = w xi yj zk, where i² = j² = k² = -1. Quaternions represent rotation as a single operation around a unit axis. They are widely used in computer graphics and robotics because they allow smooth spherical interpolation (slerp) and are numerically stable. Every 3D engine—whether Unity, Unreal, or custom—uses quaternions under the hood for camera and object orientation.

Coordinate Systems and Transformations

Every 3D scene relies on a hierarchy of coordinate spaces: model space, world space, view space (camera space), and clip space. The Model-View-Projection (MVP) matrix is a product of three matrices: the model matrix (places objects in the world), the view matrix (moves the camera to the origin), and the projection matrix (creates perspective or orthographic flattening). Understanding how to combine these transforms is critical for rendering. Without proper matrix math, objects would appear distorted or in the wrong position. The entire pipeline of a renderer is built on linear algebra.

Practical Application: Ray Casting and Collision

Beyond rendering, 3D math is the backbone of physics and interaction. Raycasting uses a vector (origin direction) to test intersections with triangles, spheres, or AABBs (axis-aligned bounding boxes). The math involves solving quadratic equations or using barycentric coordinates. Cross products are used to compute surface normals, which determine how light bounces off an object. Even a simple click-to-select operation in a 3D game traces a ray from the mouse position into the scene—pure vector and matrix math.

This page was generated by AI. It is not a source of trustworthy medical information.
The curated page