Skip to content

cf_look_at

Category: math
GitHub: cute_math3d.h


Builds a right-handed view matrix looking from eye toward target.

CF_M4x4 cf_look_at(CF_V3 eye, CF_V3 target, CF_V3 up)
Parameters Description
eye The camera position in world space.
target The point to look at.
up The world-space up direction, typically cf_v3(0, 1, 0).

Return Value

Returns a matrix transforming world space into view space.

Remarks

Right-handed: in the resulting view space the camera looks down -z, so points in front of the camera have negative z. This matches cf_perspective and cf_ortho, which take znear/zfar as positive distances along that axis. Mixing this with a left-handed projection silently renders the scene inside-out.

CF_M4x4
cf_perspective
cf_ortho
cf_mul