Crate truck_geometry::base::cgmath
Expand description
A low-dimensional linear algebra library, targeted at computer graphics.
Trait overview
In order to make a clean, composable API, we divide operations into traits that are roughly based on mathematical properties. The main ones that we concern ourselves with are listed below:
VectorSpace
: Specifies the main operators for vectors, quaternions, and matrices.MetricSpace
: For types that have a distance function implemented.InnerSpace
: For types that have a dot (or inner) product - ie. vectors or quaternions. This also allows for the definition of operations that are based on the dot product, like finding the magnitude or normalizing.EuclideanSpace
: Points in euclidean space, with an associated space of displacement vectors.Matrix
: Common operations for matrices of arbitrary dimensions.SquareMatrix
: A special trait for matrices where the number of columns equal the number of rows.
Other traits are included for practical convenience, for example:
Array
: For contiguous, indexable arrays of elements, specifically vectors.ElementWise
: For element-wise addition, subtraction, multiplication, division, and remainder operations.
The prelude
Importing each trait individually can become a chore, so we provide a
prelude
module to allow you to import the main traits all at once. For
example:
use cgmath::prelude::*;
Modules
Constrained conversion functions for assisting in situations where type
inference is difficult.
Numeric traits for generic mathematics
This module contains the most common traits used in
cgmath
. By
glob-importing this module, you can avoid the need to import each trait
individually, while still being selective about what types you import.Macros
Approximate equality of using the absolute difference.
Approximate inequality of using the absolute difference.
An assertion that delegates to [
abs_diff_eq!
], and panics with a helpful error on failure.An assertion that delegates to [
abs_diff_ne!
], and panics with a helpful error on failure.An assertion that delegates to [
relative_eq!
], and panics with a helpful error on failure.An assertion that delegates to [
relative_ne!
], and panics with a helpful error on failure.An assertion that delegates to [
ulps_eq!
], and panics with a helpful error on failure.An assertion that delegates to [
ulps_ne!
], and panics with a helpful error on failure.Approximate equality using both the absolute difference and relative based comparisons.
Approximate inequality using both the absolute difference and relative based comparisons.
Approximate equality using both the absolute difference and ULPs (Units in Last Place).
Approximate inequality using both the absolute difference and ULPs (Units in Last Place).
Structs
The requisite parameters for testing for approximate equality using a
absolute difference based comparison.
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 set of Euler angles representing a rotation in three-dimensional space.
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 1-dimensional space.
A point in 2-dimensional space.
A point in 3-dimensional space.
A quaternion in scalar/vector
form.
An angle, in radians.
The requisite parameters for testing for approximate equality using a
relative based comparison.
The requisite parameters for testing for approximate equality using an ULPs
based comparison.
A 1-dimensional vector.
A 2-dimensional vector.
A 3-dimensional vector.
A 4-dimensional vector.
Traits
Equality that is defined using the absolute difference of two numbers.
Angles and their associated trigonometric functions.
An array containing elements of type
Element
Base floating point types
Base numeric types with partial ordering
Numbers which have upper and lower bounds
Element-wise arithmetic operations. These are supplied for pragmatic
reasons, but will usually fall outside of traditional algebraic properties.
Points in a Euclidean space
with an associated space of displacement vectors.
A column-major matrix of arbitrary dimensions.
A type with a distance function between values.
Defines a multiplicative identity element for
Self
.Equality comparisons between two numbers using both the absolute difference and
relative based comparisons.
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
Equality comparisons between two numbers using both the absolute difference and ULPs
(Units in Last Place) based comparisons.
Vectors that can be added
together and multiplied
by scalars.
Defines an additive identity element for
Self
.Functions
Dot product of two vectors.
Create a perspective matrix from a view frustum.
Create an orthographic projection matrix.
Create a perspective projection matrix.
The short constructor.
The short constructor.
The short constructor.
The short constructor.
The short constructor.
The short constructor.
The short constructor.