Skip to content

cf_orthonormal_basis

Category: math
GitHub: cute_math3d.h


Builds two unit vectors perpendicular to n and to each other.

void cf_orthonormal_basis(CF_V3 n, CF_V3* x_out, CF_V3* y_out)
Parameters Description
n The third axis of the basis. Should be unit length.
x_out Written with the first perpendicular axis.
y_out Written with the second perpendicular axis.

Remarks

(x, y, n) form a right-handed orthonormal basis: cross(x, y) == n. Branchless and stable for every unit n (the Duff et al. method). The tangents are arbitrary but deterministic -- right for sampling disks and cones around a normal, spawning particles off a surface, or framing a camera ribbon; wrong for mesh tangent spaces, which must come from UVs.

CF_V3
cf_cross
cf_quat_from_basis
cf_quat_from_to