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

  • Operations on angles.
  • An array containing elements of type Element
  • Base floating point types
  • Base integer types
  • Base numeric types with partial ordering
  • Specifies geometric operations for vectors. This is only implemented for 2-dimensional and 3-dimensional vectors.
  • A column-major matrix of arbitrary dimensions.
  • Defines a multiplicative identity element for Self.
  • A trait providing a partial ordering.
  • Specifies the numeric operations for point types.
  • A trait for a generic rotation. A rotation is a transformation that creates a circular motion, and preserves at least one point in the space.
  • A two-dimensional rotation.
  • A three-dimensional rotation.
  • A column-major major matrix where the rows and column vectors are of the same dimensions.
  • A trait representing an affine transformation that can be applied to points or vectors. An affine transformation is one which
  • A trait that specifies a range of numeric operations for vectors. Not all of these make sense from a linear algebra point of view, but are included for pragmatic reasons.
  • Defines an additive identity element for Self.

Functions

  • Create a new angle, in degrees
  • Dot product of two vectors.
  • Create a perspective matrix from a view frustrum.
  • Returns the multiplicative identity, 1.
  • Create an orthographic projection matrix.
  • Create a perspective projection matrix.
  • Create a new angle, in radians
  • The short constructor.
  • The short constructor.
  • The short constructor.
  • Returns the additive identity, 0.