Crate cgmath

source ·
Expand description

Computer graphics-centric math.

This crate provides useful mathematical primitives and operations on them. It is organized into one module per primitive. The core structures are vectors and matrices. A strongly-typed interface is provided, to prevent mixing units or violating mathematical invariants.

Transformations are not usually done directly on matrices, but go through transformation objects that can be converted to matrices. Rotations go through the Basis types, which are guaranteed to be orthogonal matrices. Despite this, one can directly create a limited rotation matrix using the look_at, from_angle, from_euler, and from_axis_angle methods. These are provided for convenience.

Macros

Structs

  • A homogeneous transformation matrix.
  • A two-dimensional rotation matrix.
  • A three-dimensional rotation matrix.
  • A generic transformation consisting of a rotation, displacement vector and scale amount.
  • An angle, in degrees
  • A 2 x 2, column major matrix
  • A 3 x 3, column major matrix
  • A 4 x 4, column major matrix
  • An orthographic projection with arbitrary left/right/bottom/top distances
  • A perspective projection with arbitrary left/right/bottom/top distances
  • A perspective projection based on a vertical field-of-view angle.
  • A point in 2-dimensional space.
  • A point in 3-dimensional space.
  • A quaternion in scalar/vector form.
  • An angle, in radians

Traits

Functions