Module munum::transform

source ·
Expand description

Transformation matrix functions.

Functions§

  • Inverts a Mat4 that represents a valid transformation in TRS order (= translation * rotation * scale). This function is more efficient than Mat4::invert by leveraging the properties of a TRS matrix.
  • Calculate the 4x4 view matrix for a camera at eye position looking at the center position with a given up direction.
  • Calculate the look-at direction {@link Vec3} vector from pitch (up/down) and yaw (left/right) angles in radians. It looks towards -Z axis when pitch = 0 and yaw = 0. This can be used with look_at method to build an FPS camera view matrix by: view_matrix = look_at(eye, eye + look_at_direction(yaw, pitch)), vec3(0, 1, 0))
  • Creates the {@link Mat4} orthographic projection matrix. To apply a glTF orthographic camera, use: left = -xmag, right = xmag, bottom = -ymag, top = ymag. See: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#projection-matrices
  • Creates the 4x4 perspective projection using glTF’s formula. Uses infinite projection if zfar = Infinity. See: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#projection-matrices
  • Creates the 4x4 perspective projection from viewport and range. Uses infinite projection if zfar = Infinity.
  • Creates a 4x4 transformation matrix that represents a rotation by a quaternion.
  • Extracts the rotation quaternion component from a 4x4 TRS transformation matrix.
  • Creates a 4x4 transformation matrix that represents a scaling of (x, y, z).
  • Extracts the (x, y, z) scaling component from a 4x4 TRS transformation matrix.
  • Calculates the Mat4 model matrix for a camera at eye position looking at the center position with a given up direction.
  • Creates a 4x4 matrix that represents a transformation in TRS order (= translation * rotation * scaling).
  • Creates a 4x4 transformation matrix that represents a translation of (x, y, z).
  • Extracts the (x, y, z) translation component from a 4x4 TRS transformation matrix.