Euclidean Length/Magnitude | |
= 0 if | Dot Product |
Cross Product | |
Projection of v onto w | |
Perpindicular of v onto w | |
Point | |
Vector |
L(t) = P + tv or S + tv = L(t) = P + t(Q-P) for 2 points | Line equation |
Distance of point S to line L(t) | |
Plane Equation | |
without abs, if d>0, p1 on same side, if d<0, opposite side | Distance of point P1 to plane |
Line is parallel to plane (v from line, n from plane) | |
Line in plane if parallel and satisfies plane equation | |
Intersection point t of line L(t) which intersects with plane (if not parallel) | |
k < 0: P1 right of L(t), k > 0: P1 left of L(t), else P1 in L(t) | Left-right of point P1, parallel vec v, and plane (P0,n) |
T(u+v) = T(u)+T(v) T(au) = aT(u) | Linear transformation definition |
Translation matrix | |
Rotation matrix about x axis | |
Rotation matrix about y axis | |
Rotation matrix about z axis | |
Rotation matrix about normalized r=(x,y,z), c=cos(θ), s=sin(θ), t=1-cos(θ) | |
Rodriguez rotation formaula about normalized axis r=(x,y,z) | |
Scale Matrix | |
Reflection matrix about plane normalized normal n=(x,y,z) | |
Reflection function about normalized n=(x,y,z) | |
Transform when not at origin, relative to point C | |
Transformation order |
Determinant of 3x3 matrix A | |
Determinant of 4x4 matrix A | |
Combined TRS matrix form | |
World matrix Wb relative to A's local space |
Euler Angle Rotation Matrix | |
Quaternion Representation | |
Quaternion dot product | |
Quaternion Length/Magnitude | |
Normalize Quaternion | |
Quaternion Multiplication | |
Quaternion Inverse | |
Quaternion form of vector v | |
Rotating vector p=(0,v) using quaternion | |
Quaternion to axis-angle | |
Quaternion to rotation matrix |
Cpos = position Tpos = target position/lookat position vdir = normalize(Tpos - Cpos) up dir given left-hand camera: local z vec = vfwd = vdir right-hand camera: local z vec = vfwd = -vdir |
Camera vectors/view direction |
Camera view-to-world matrix | |
Camera world-to-view matrix | |
Orthographic projection matrix (right-hand camera using ndc -1,1) | |
Perspective projection matrix (right-hand camera, left-hand ndc -1,1). d = cot(theta/2), a = aspect ratio = width/height After multiplying camera-space point by this, remember to divide by w to get final 3d point in NDC coordinates |
|
ndc to screen matrix, dz = depth used |
Culling given face normal n and line of sight direction vlos | |
Normal n calculation given triangle with points a,b,c | |
vlos calc using perspective projection camera, triangle world space points (p1,p2,p3) | |
vlos calc using orthographic camera |
Near plane p0 = Far plane p1 = |
Screen space to world space for object picking. Divide by w as the last step (after multiplying by Mview-to-world) |
length(P-C) < r then P inside, else outside | Point P and Bsphere=(C,r) collision, Bsphere C and r both in world space |
length(C-C') < r + r' then intersects, else no intersection | Bsphere(C,r) and BSphere(C',r') collision, both Bspheres C/r in world space |
min.x < P.x < max.x AND min.y < P.y < max.y AND min.z < P.z < max.z then P inside A, else not |
AABB-point P intersection |
Test if intervals (a,b) and (c,d) overlap: if (b<c) or (d<a) then return false (no overlap) else return true (overlap) |
Interval overlap test |
Clamping c to interval (a,b): if c < a return a else if b < c return b else return c |
Clamping function on scalar to interval. To clamp point between (min,max) apply clamp to x,y,z |
p' = clamp(C',(min,max)) test p' point intersection with Bsphere |
Bsphere-AABB collision test, using world-space bpshere C'/r' |
Compute Compute Compute Test if point Q' is in Bsphere |
OBB using matrix W and Bsphere(C'_N,r_N) intersection (C'_N world space) |
calc calc proj_max = return s2 proj_max |
Max obb projection on axis v. OBB has tform W, (a,b,c) = max-min, s = length of first column of W (assuming uniform scale). |
Proj1 = Max OBB1 projection on Axis v Proj2 = Max OBB2 projection on Axis v if D ≤ Proj1 + Proj2 then return true (overlap), else false (no overlap) |
OBB,OBB axis overlap along axis v. If any axis returns no overlap, then no intersection; else intersection. C1,C2 in world space |
Treat AABB as OBB then do OBB/OBB intersection | AABB vs OBB intersection |
Point Q' on line (L(t) = P + tv) that is closest to given P given Q | |
Distance from point Q to line L(t) = P + tv | |
Line segment definition, 0 ≤ t ≤ 1 | |
if t < 0 then return if t > 1 then return else return |
Closest point Q' on segment S(t) to point Q. distance from point Q to S(t) is ||Q' - Q||. |
ray definition, t ≥ 0 | |
if t < 0 return else return |
Closest point on ray R(t) to point Q. |
if t < 0 then t = 0 return |
Ray(P,v) Bsphere(C,r) intersection |
Line-line closest points if if |
|
Variables for line-line intersection | |
Line-line closest points if |
|
Distance |
Line-line intersection/distance between closest points |
if if ( else [ else if (repeat above for y,z axis) if [s_x,t_x] overlaps [s_y,t_y] AND [s_y,t_y] overlaps [s_z,t_z] AND [s_z,t_z] overlaps [s_x,t_x] return true |
Line-AABB intersection fro L(P_0,v) and AABB(Max,Min) |
Convert line to OBB's local space where the OBB is AABB and use above method | Line-OBB intersection |
if d < r then intersection, else no intersection |
Plane-Bsphere intersection. Without abs, if = 0 then C in plane, if d > 0 then C above plane (same side as n), if d < 0 then C below plane (opposite side as n). |
if 0 ≤ t' ≤ 1 then intersection, else no intersection |
Plane P0,n segment S(t) = S1 + t(S2 - S1) collision method 1 |
if ( |
Plane segmend collision method 2 (only gives yes/no) |
h = OBB half projection on return d1 < 0 AND d2 > 0 |
OBB(max,min) and Plane(P0,n) collision. OBB half = (max-min)*0.5. Projection axis v = n |
Linear interpolation at time t given points P and times | |
Catmull-Rom interpolation at time t given points P and times | |
Cubic Bezier Interpolation at time t given points P, control points C, and times | |
Quadratic Bezier Interpolation at time t given points P, control points C, and times | |
Spherical-linear interpolation (slerp) on quaternions p and q at time u in 0..1 |