Expand description
§nalgebra-glm − nalgebra in easy mode
nalgebra-glm is a GLM-like interface for the nalgebra general-purpose linear algebra library. GLM itself is a popular C++ linear algebra library essentially targeting computer graphics. Therefore nalgebra-glm draws inspiration from GLM to define a nice and easy-to-use API for simple graphics application.
All the types of nalgebra-glm are aliases of types from nalgebra. Therefore there is a complete and seamless inter-operability between both.
§Getting started
First of all, you should start by taking a look at the official GLM API documentation
since nalgebra-glm implements a large subset of it. To use nalgebra-glm to your project, you
should add it as a dependency to your Crates.toml
:
[dependencies]
nalgebra-glm = "0.3"
Then, you should add an extern crate
statement to your lib.rs
or main.rs
file. It is strongly
recommended to add a crate alias to glm
as well so that you will be able to call functions of
nalgebra-glm using the module prefix glm::
. For example you will write glm::rotate(...)
instead
of the more verbose nalgebra_glm::rotate(...)
:
extern crate nalgebra_glm as glm;
§Features overview
nalgebra-glm supports most linear-algebra related features of the C++ GLM library. Mathematically speaking, it supports all the common transformations like rotations, translations, scaling, shearing, and projections but operating in homogeneous coordinates. This means all the 2D transformations are expressed as 3x3 matrices, and all the 3D transformations as 4x4 matrices. This is less computationally-efficient and memory-efficient than nalgebra’s transformation types, but this has the benefit of being simpler to use.
§Main differences compared to GLM
While nalgebra-glm follows the feature line of the C++ GLM library, quite a few differences remain and they are mostly syntactic. The main ones are:
- All function names use
snake_case
, which is the Rust convention. - All type names use
CamelCase
, which is the Rust convention. - All function arguments, except for scalars, are all passed by-reference.
- The most generic vector and matrix types are
TMat
andTVec
instead ofmat
andvec
. - Some feature are not yet implemented and should be added in the future. In particular, no packing functions are available.
- A few features are not implemented and will never be. This includes functions related to color spaces, and closest points computations. Other crates should be used for those. For example, closest points computation can be handled by the ncollide project.
In addition, because Rust does not allows function overloading, all functions must be given a unique name. Here are a few rules chosen arbitrarily for nalgebra-glm:
- Functions operating in 2d will usually end with the
2d
suffix, e.g.,glm::rotate2d()
is for 2D whileglm::rotate()
is for 3D. - Functions operating on vectors will often end with the
_vec
suffix, possibly followed by the dimension of vector, e.g.,glm::rotate_vec2()
. - Every function related to quaternions start with the
quat_
prefix, e.g.,glm::quat_dot(q1, q2)
. - All the conversion functions have unique names as described below.
§Vector and matrix construction
Vectors, matrices, and quaternions can be constructed using several approaches:
- Using functions with the same name as their type in lower-case. For example
glm::vec3(x, y, z)
will create a 3D vector. - Using the
::new
constructor. For exampleVec3::new(x, y, z)
will create a 3D vector. - Using the functions prefixed by
make_
to build a vector a matrix from a slice. For exampleglm::make_vec3(&[x, y, z])
will create a 3D vector. Keep in mind that constructing a matrix using this type of functions require its components to be arranged in column-major order on the slice. - Using a geometric construction function. For example
glm::rotation(angle, axis)
will build a 4x4 homogeneous rotation matrix from an angle (in radians) and an axis. - Using swizzling and conversions as described in the next sections.
§Swizzling
Vector swizzling is a native feature of nalgebra itself. Therefore, you can use it with all
the vectors of nalgebra-glm as well. Swizzling is supported as methods and works only up to
dimension 3, i.e., you can only refer to the components x
, y
and z
and can only create a
2D or 3D vector using this technique. Here is some examples, assuming v
is a vector with float
components here:
v.xx()
is equivalent toglm::vec2(v.x, v.x)
and toVec2::new(v.x, v.x)
.v.zx()
is equivalent toglm::vec2(v.z, v.x)
and toVec2::new(v.z, v.x)
.v.yxz()
is equivalent toglm::vec3(v.y, v.x, v.z)
and toVec3::new(v.y, v.x, v.z)
.v.zzy()
is equivalent toglm::vec3(v.z, v.z, v.y)
and toVec3::new(v.z, v.z, v.y)
.
Any combination of two or three components picked among x
, y
, and z
will work.
§Conversions
It is often useful to convert one algebraic type to another. There are two main approaches for converting
between types in nalgebra-glm
:
- Using function with the form
type1_to_type2
in order to convert an instance oftype1
into an instance oftype2
. For exampleglm::mat3_to_mat4(m)
will convert the 3x3 matrixm
to a 4x4 matrix by appending one column on the right and one row on the left. Those now row and columns are filled with 0 except for the diagonal element which is set to 1. - Using one of the
convert
,try_convert
, orconvert_unchecked
functions. These functions are directly re-exported from nalgebra and are extremely versatile:- The
convert
function can convert any type (especially geometric types from nalgebra likeIsometry3
) into another algebraic type which is equivalent but more general. For example,let sim: Similarity3<_> = na::convert(isometry)
will convert anIsometry3
into aSimilarity3
. In addition,let mat: Mat4 = glm::convert(isometry)
will convert anIsometry3
to a 4x4 matrix. This will also convert the scalar types, therefore:let mat: DMat4 = glm::convert(m)
wherem: Mat4
will work. However, conversion will not work the other way round: you can’t convert aMatrix4
to anIsometry3
usingglm::convert
because that could cause unexpected results if the matrix does not complies to the requirements of the isometry. - If you need this kind of conversions anyway, you can use
try_convert
which will test if the object being converted complies with the algebraic requirements of the target type. This will returnNone
if the requirements are not satisfied. - The
convert_unchecked
will ignore those tests and always perform the conversion, even if that breaks the invariants of the target type. This must be used with care! This is actually the recommended method to convert between homogeneous transformations generated bynalgebra-glm
and specific transformation types from nalgebra likeIsometry3
. Just be careful you know your conversions make sense.
- The
§Should I use nalgebra or nalgebra-glm?
Well that depends on your tastes and your background. nalgebra is more powerful overall since it allows stronger typing, and goes much further than simple computer graphics math. However, has a bit of a learning curve for those not used to the abstract mathematical concepts for transformations. nalgebra-glm however have more straightforward functions and benefit from the various tutorials existing on the internet for the original C++ GLM library.
Overall, if you are already used to the C++ GLM library, or to working with homogeneous coordinates (like 4D matrices for 3D transformations), then you will have more success with nalgebra-glm. If on the other hand you prefer more rigorous treatments of transformations, with type-level restrictions, then go for nalgebra. If you need dynamically-sized matrices, you should go for nalgebra as well.
Keep in mind that nalgebra-glm is just a different API for nalgebra. So you can very well use both
and benefit from both their advantages: use nalgebra-glm when mathematical rigor is not that important,
and nalgebra itself when you need more expressive types, and more powerful linear algebra operations like
matrix factorizations and slicing. Just remember that all the nalgebra-glm types are just aliases to nalgebra types,
and keep in mind it is possible to convert, e.g., an Isometry3
to a Mat4
and vice-versa (see the conversions section).
Structs§
- Default
Allocator - An allocator based on
ArrayStorage
andVecStorage
for statically-sized and dynamically-sized matrices respectively.
Constants§
- U1
- The constant dimension 1.
- U2
- The constant dimension 2 .
- U3
- The constant dimension 3 .
- U4
- The constant dimension 4 .
Traits§
- Number
- A number that can either be an integer or a float.
- Real
Number - A number that can be any float type.
- Scalar
- The basic scalar type for all structures of
nalgebra
.
Functions§
- abs
- For each matrix or vector component
x
ifx >= 0
; otherwise, it returns-x
. - acos
- Component-wise arc-cosinus.
- acosh
- Component-wise hyperbolic arc-cosinus.
- affine_
inverse - Fast matrix inverse for affine matrix.
- all
- Checks that all the vector components are
true
. - angle
- The angle between two vectors.
- any
- Checks that at least one of the vector components is
true
. - are_
collinear - Returns
true
if two vectors are collinear (up to an epsilon). - are_
collinear2d - Returns
true
if two 2D vectors are collinear (up to an epsilon). - are_
orthogonal - Returns
true
if two vectors are orthogonal (up to an epsilon). - asin
- Component-wise arc-sinus.
- asinh
- Component-wise hyperbolic arc-sinus.
- atan
- Component-wise arc-tangent.
- atan2
- Component-wise arc-tangent of
y / x
. - atanh
- Component-wise hyperbolic arc-tangent.
- ceil
- For each matrix or vector component returns a value equal to the nearest integer that is greater than or equal to
x
. - clamp
- Returns
min(max(x[i], min_val), max_val)
for each component inx
using the valuesmin_val and
max_val` as bounds. - clamp_
scalar - Returns
min(max(x, min_val), max_val)
. - clamp_
vec - Returns
min(max(x[i], min_val[i]), max_val[i])
for each component inx
using the components ofmin_val
andmax_val
as bounds. - column
- The
index
-th column of the matrixm
. - comp_
add - The sum of every component of the given matrix or vector.
- comp_
max - The maximum of every component of the given matrix or vector.
- comp_
min - The minimum of every component of the given matrix or vector.
- comp_
mul - The product of every component of the given matrix or vector.
- convert
- Converts an object from one type to an equivalent or more general one.
- convert_
ref - Converts an object from one type to an equivalent or more general one.
- convert_
ref_ unchecked - Use with care! Same as
try_convert()
but without any property checks. - convert_
unchecked - Use with care! Same as
try_convert()
but without any property checks. - cos
- Component-wise cosinus.
- cosh
- Component-wise hyperbolic cosinus.
- cross
- The cross product of two vectors.
- cross2d
- The 2D perpendicular product between two vectors.
- degrees
- Component-wise conversion from radians to degrees.
- determinant
- The determinant of the matrix
m
. - diagonal2x2
- Builds a 2x2 diagonal matrix.
- diagonal2x3
- Builds a 2x3 diagonal matrix.
- diagonal2x4
- Builds a 2x4 diagonal matrix.
- diagonal3x2
- Builds a 3x2 diagonal matrix.
- diagonal3x3
- Builds a 3x3 diagonal matrix.
- diagonal3x4
- Builds a 3x4 diagonal matrix.
- diagonal4x2
- Builds a 4x2 diagonal matrix.
- diagonal4x3
- Builds a 4x3 diagonal matrix.
- diagonal4x4
- Builds a 4x4 diagonal matrix.
- distance
- The distance between two points.
- distance2
- The squared distance between two points.
- dot
- The dot product of two vectors.
- e
- The Euler constant.
- epsilon
- Default epsilon value used for approximate comparison.
- equal
- Component-wise equality comparison.
- equal_
columns - Perform a component-wise equal-to comparison of two matrices.
- equal_
columns_ eps - Returns the component-wise comparison of
|x - y| < epsilon
. - equal_
columns_ eps_ vec - Returns the component-wise comparison on each matrix column
|x - y| < epsilon
. - equal_
eps - Component-wise approximate equality of two vectors, using a scalar epsilon.
- equal_
eps_ vec - Component-wise approximate equality of two vectors, using a per-component epsilon.
- euler
- The Euler constant.
- exp
- Component-wise exponential.
- exp2
- Component-wise base-2 exponential.
- faceforward
- If
dot(nref, i) < 0.0
, returnn
, otherwise, return-n
. - fast_
normalize_ dot - The dot product of the normalized version of
x
andy
. - float_
bits_ to_ int - Returns a signed integer value representing the encoding of a floating-point value.
- float_
bits_ to_ int_ vec - Returns a signed integer value representing the encoding of each component of
v
. - float_
bits_ to_ uint - Returns an unsigned integer value representing the encoding of a floating-point value.
- float_
bits_ to_ uint_ vec - Returns an unsigned integer value representing the encoding of each component of
v
. - floor
- Returns componentwise a value equal to the nearest integer that is less then or equal to
x
. - four_
over_ pi - Returns
4 / pi
. - fract
- Returns the fractional part of each component of
x
. - golden_
ratio - Returns the golden ratio.
- greater_
than - Component-wise
>
comparison. - greater_
than_ equal - Component-wise
>=
comparison. - half_pi
- Returns
pi / 2
. - identity
- The identity matrix.
- infinite_
perspective_ rh_ no - Build infinite right-handed perspective projection matrix with [-1,1] depth range.
- infinite_
perspective_ rh_ zo - Build infinite right-handed perspective projection matrix with [0,1] depth range.
- int_
bits_ to_ float - Returns a floating-point value corresponding to a signed integer encoding of a floating-point value.
- int_
bits_ to_ float_ vec - For each components of
v
, returns a floating-point value corresponding to a signed integer encoding of a floating-point value. - inverse
- The inverse of the matrix
m
. - inverse_
transpose - Compute the transpose of the inverse of a matrix.
- inversesqrt
- Compute the inverse of the square root of each component of
v
. - is_
comp_ null - Returns
true
if all the components ofv
are zero (up to an epsilon). - is_
normalized - Returns
true
ifv
has a magnitude of 1 (up to an epsilon). - is_null
- Returns
true
ifv
is zero (up to an epsilon). - l1_
distance - The l1-norm of
x - y
. - l1_norm
- The l1-norm of
v
. - l2_
distance - The l2-norm of
x - y
. - l2_norm
- The l2-norm of
v
. - left_
handed - Returns
true
if{a, b, c}
forms a left-handed trihedron. - length
- The magnitude of a vector.
- length2
- The squared magnitude of
x
. - lerp
- Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the vectors x and y using the scalar value a. - lerp_
scalar - Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the scalars x and y using the scalar value a. - lerp_
vec - Returns
x * (1.0 - a) + y * a
, i.e., the component-wise linear blend ofx
andy
using the components of the vectora
as coefficients. - less_
than - Component-wise
<
comparison. - less_
than_ equal - Component-wise
<=
comparison. - ln_
ln_ two - Returns
ln(ln(2))
. - ln_ten
- Returns
ln(10)
. - ln_two
- Returns
ln(2)
. - log
- Component-wise logarithm.
- log2
- Component-wise base-2 logarithm.
- look_at
- Build a look at view matrix based on the right handedness.
- look_
at_ lh - Build a left handed look at view matrix.
- look_
at_ rh - Build a right handed look at view matrix.
- magnitude
- The magnitude of a vector.
- magnitude2
- The squared magnitude of
x
. - make_
mat2 - Creates a 2x2 matrix from a slice arranged in column-major order.
- make_
mat3 - Creates a 3 matrix from a slice arranged in column-major order.
- make_
mat4 - Creates a 4x4 matrix from a slice arranged in column-major order.
- make_
mat2x2 - Creates a 2x2 matrix from a slice arranged in column-major order.
- make_
mat2x3 - Creates a 2x3 matrix from a slice arranged in column-major order.
- make_
mat2x4 - Creates a 2x4 matrix from a slice arranged in column-major order.
- make_
mat3x2 - Creates a 3x2 matrix from a slice arranged in column-major order.
- make_
mat3x3 - Creates a 3x3 matrix from a slice arranged in column-major order.
- make_
mat3x4 - Creates a 3x4 matrix from a slice arranged in column-major order.
- make_
mat4x2 - Creates a 4x2 matrix from a slice arranged in column-major order.
- make_
mat4x3 - Creates a 4x3 matrix from a slice arranged in column-major order.
- make_
mat4x4 - Creates a 4x4 matrix from a slice arranged in column-major order.
- make_
quat - Creates a quaternion from a slice arranged as
[x, y, z, w]
. - make_
vec1 - Creates a 1D vector from a slice.
- make_
vec2 - Creates a 2D vector from a slice.
- make_
vec3 - Creates a 3D vector from another vector.
- make_
vec4 - Creates a 4D vector from another vector.
- mat2
- Create a new 2x2 matrix.
- mat3
- Create a new 3x3 matrix.
- mat4
- Create a new 4x4 matrix.
- mat2_
to_ mat3 - Converts a 2x2 matrix to a 3x3 matrix.
- mat2_
to_ mat4 - Converts a 2x2 matrix to a 4x4 matrix.
- mat2x2
- Create a new 2x2 matrix.
- mat2x3
- Create a new 2x3 matrix.
- mat2x4
- Create a new 2x4 matrix.
- mat3_
to_ mat2 - Converts a 3x3 matrix to a 2x2 matrix.
- mat3_
to_ mat4 - Converts a 3x3 matrix to a 4x4 matrix.
- mat3_
to_ quat - Converts a rotation matrix to a quaternion.
- mat3x2
- Create a new 3x2 matrix.
- mat3x3
- Create a new 3x3 matrix.
- mat3x4
- Create a new 3x4 matrix.
- mat4_
to_ mat2 - Converts a 4x4 matrix to a 2x2 matrix.
- mat4_
to_ mat3 - Converts a 4x4 matrix to a 3x3 matrix.
- mat4x2
- Create a new 4x2 matrix.
- mat4x3
- Create a new 4x3 matrix.
- mat4x4
- Create a new 4x4 matrix.
- matrix_
comp_ mult - Component-wise multiplication of two matrices.
- matrix_
cross - Builds a 4x4 matrix
m
such that for anyv
:m * v == cross(x, v)
. - matrix_
cross3 - Builds a 3x3 matrix
m
such that for anyv
:m * v == cross(x, v)
. - max
- Component-wise maximum between a vector and a scalar.
- max2
- Component-wise maximum between two vectors.
- max3
- Component-wise maximum between three vectors.
- max4
- Component-wise maximum between four vectors.
- max2_
scalar - Returns the maximum among two values.
- max3_
scalar - Returns the maximum among three values.
- max4_
scalar - Returns the maximum among four values.
- min
- Component-wise minimum between a vector and a scalar.
- min2
- Component-wise minimum between two vectors.
- min3
- Component-wise minimum between three vectors.
- min4
- Component-wise minimum between four vectors.
- min2_
scalar - Returns the maximum among two values.
- min3_
scalar - Returns the minimum among three values.
- min4_
scalar - Returns the minimum among four values.
- mix
- Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the vectors x and y using the scalar value a. - mix_
scalar - Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the scalars x and y using the scalar value a. - mix_vec
- Returns
x * (1.0 - a) + y * a
, i.e., the component-wise linear blend ofx
andy
using the components of the vectora
as coefficients. - modf
- Modulus between two values.
- modf_
vec - Component-wise modulus.
- normalize
- Normalizes a vector.
- normalize_
dot - The dot product of the normalized version of
x
andy
. - not
- Component-wise not
!
. - not_
equal - Component-wise not-equality
!=
. - not_
equal_ columns - Perform a component-wise not-equal-to comparison of two matrices.
- not_
equal_ columns_ eps - Returns the component-wise comparison of
|x - y| < epsilon
. - not_
equal_ columns_ eps_ vec - Returns the component-wise comparison of
|x - y| >= epsilon
. - not_
equal_ eps - Component-wise approximate non-equality of two vectors, using a scalar epsilon.
- not_
equal_ eps_ vec - Component-wise approximate non-equality of two vectors, using a per-component epsilon.
- one
- Returns
1
. Gets the multiplicative identity element. - one_
over_ pi - Returns
1 / pi
. - one_
over_ root_ two - Returns
1 / sqrt(2)
. - one_
over_ two_ pi - Returns
1 / (2pi)
. - orientation
- Build the rotation matrix needed to align
normal
andup
. - ortho
- Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- ortho_
lh - Creates a left hand matrix for a orthographic-view frustum with a depth range of -1 to 1
- ortho_
lh_ no - Creates a left hand matrix for a orthographic-view frustum with a depth range of -1 to 1
- ortho_
lh_ zo - Creates a matrix for a left hand orthographic-view frustum with a depth range of 0 to 1
- ortho_
no - Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- ortho_
rh - Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- ortho_
rh_ no - Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- ortho_
rh_ zo - Creates a right hand matrix for a orthographic-view frustum with a depth range of 0 to 1
- ortho_
zo - Creates a right hand matrix for a orthographic-view frustum with a depth range of 0 to 1
- outer_
product - Treats the first parameter
c
as a column vector and the second parameterr
as a row vector and does a linear algebraic matrix multiplyc * r
. - perspective
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov_ lh - Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov_ lh_ no - Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov_ lh_ zo - Creates a matrix for a left hand perspective-view frustum with a depth range of 0 to 1
- perspective_
fov_ no - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov_ rh - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov_ rh_ no - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
fov_ rh_ zo - Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- perspective_
fov_ zo - Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- perspective_
lh - Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- perspective_
lh_ no - Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- perspective_
lh_ zo - Creates a matrix for a left hand perspective-view frustum with a depth range of 0 to 1
- perspective_
no - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
rh - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
rh_ no - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- perspective_
rh_ zo - Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- perspective_
zo - Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- pi
- The value of PI.
- pick_
matrix - Define a picking region.
- pow
- Component-wise power.
- proj
- Build planar projection matrix along normal axis, and right-multiply it to
m
. - proj2d
- Build planar projection matrix along normal axis and right-multiply it to
m
. - project
- Map the specified object coordinates
(obj.x, obj.y, obj.z)
into window coordinates with a depth range of -1 to 1 - project_
no - Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
- project_
zo - Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
- quarter_
pi - Returns
pi / 4
. - quat
- Creates a new quaternion.
- quat_
angle - The rotation angle of this quaternion assumed to be normalized.
- quat_
angle_ axis - Creates a quaternion from an axis and an angle.
- quat_
axis - The rotation axis of a quaternion assumed to be normalized.
- quat_
cast - Convert a quaternion to a rotation matrix in homogeneous coordinates.
- quat_
conjugate - The conjugate of
q
. - quat_
cross - Multiplies two quaternions.
- quat_
cross_ vec - Rotate the vector
v
by the quaternionq
assumed to be normalized. - quat_
dot - The scalar product of two quaternions.
- quat_
equal - Component-wise equality comparison between two quaternions.
- quat_
equal_ eps - Component-wise approximate equality comparison between two quaternions.
- quat_
euler_ angles - Euler angles of the quaternion
q
as (pitch, yaw, roll). - quat_
exp - Computes the quaternion exponential.
- quat_
extract_ real_ component - The quaternion
w
component. - quat_
fast_ mix - Normalized linear interpolation between two quaternions.
- quat_
greater_ than - Component-wise
>
comparison between two quaternions. - quat_
greater_ than_ equal - Component-wise
>=
comparison between two quaternions. - quat_
identity - The quaternion representing the identity rotation.
- quat_
inv_ cross_ vec - Rotate the vector
v
by the inverse of the quaternionq
assumed to be normalized. - quat_
inverse - The inverse of
q
. - quat_
length - The magnitude of the quaternion
q
. - quat_
length2 - The squared magnitude of a quaternion
q
. - quat_
lerp - Interpolate linearly between
x
andy
. - quat_
less_ than - Component-wise
<
comparison between two quaternions. - quat_
less_ than_ equal - Component-wise
<=
comparison between two quaternions. - quat_
log - Computes the quaternion logarithm.
- quat_
look_ at - Computes a right hand look-at quaternion
- quat_
look_ at_ lh - Computes a left-handed look-at quaternion (equivalent to a left-handed look-at matrix).
- quat_
look_ at_ rh - Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix).
- quat_
magnitude - The magnitude of the quaternion
q
. - quat_
magnitude2 - The squared magnitude of a quaternion
q
. - quat_
normalize - Normalizes the quaternion
q
. - quat_
not_ equal - Component-wise non-equality comparison between two quaternions.
- quat_
not_ equal_ eps - Component-wise approximate non-equality comparison between two quaternions.
- quat_
pitch - The “pitch” Euler angle of the quaternion
x
assumed to be normalized. - quat_
pow - Raises the quaternion
q
to the powery
. - quat_
roll - The “roll” Euler angle of the quaternion
x
assumed to be normalized. - quat_
rotate - Builds a quaternion from an axis and an angle, and right-multiply it to the quaternion
q
. - quat_
rotate_ normalized_ axis - Rotates a quaternion from a vector of 3 components normalized axis and an angle.
- quat_
rotate_ vec - Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized.
- quat_
rotate_ vec3 - Rotates a vector by a quaternion assumed to be normalized.
- quat_
rotation - The rotation required to align
orig
todest
. - quat_
short_ mix - The spherical linear interpolation between two quaternions.
- quat_
slerp - Interpolate spherically between
x
andy
. - quat_
to_ mat3 - Converts a quaternion to a rotation matrix.
- quat_
to_ mat4 - Converts a quaternion to a rotation matrix in homogeneous coordinates.
- quat_
yaw - The “yaw” Euler angle of the quaternion
x
assumed to be normalized. - radians
- Component-wise conversion from degrees to radians.
- reflect
- Builds a reflection matrix, and right-multiply it to
m
. - reflect2d
- Builds a reflection matrix and right-multiply it to
m
. - reflect_
vec - For the incident vector
i
and surface orientationn
, returns the reflection direction :result = i - 2.0 * dot(n, i) * n
. - refract_
vec - For the incident vector
i
and surface normaln
, and the ratio of indices of refractioneta
, return the refraction vector. - reversed_
infinite_ perspective_ rh_ zo - Build an infinite perspective projection matrix with a reversed [0, 1] depth range.
- reversed_
perspective_ rh_ zo - Creates a matrix for a right hand perspective-view frustum with a reversed depth range of 0 to 1.
- right_
handed - Returns
true
if{a, b, c}
forms a right-handed trihedron. - root_
five - Returns
sqrt(5)
. - root_
half_ pi - Returns
sqrt(pi / 2)
. - root_
ln_ four - Returns
sqrt(ln(4))
. - root_pi
- Returns the square root of pi.
- root_
three - Returns the square root of 3.
- root_
two - Returns the square root of 2.
- root_
two_ pi - Returns the square root of 2pi.
- rotate
- Builds a rotation 4 * 4 matrix created from an axis vector and an angle and right-multiply it to
m
. - rotate2d
- Builds a 2D rotation matrix from an angle and right-multiply it to
m
. - rotate_
normalized_ axis - Builds a rotation 4 * 4 matrix created from a normalized axis and an angle.
- rotate_
vec2 - Rotate a two dimensional vector.
- rotate_
vec3 - Rotate a three dimensional vector around an axis.
- rotate_
vec4 - Rotate a thee dimensional vector in homogeneous coordinates around an axis.
- rotate_
x - Builds a rotation 4 * 4 matrix around the X axis and right-multiply it to
m
. - rotate_
x_ vec3 - Rotate a three dimensional vector around the
X
axis. - rotate_
x_ vec4 - Rotate a three dimensional vector in homogeneous coordinates around the
X
axis. - rotate_
y - Builds a rotation 4 * 4 matrix around the Y axis and right-multiply it to
m
. - rotate_
y_ vec3 - Rotate a three dimensional vector around the
Y
axis. - rotate_
y_ vec4 - Rotate a three dimensional vector in homogeneous coordinates around the
Y
axis. - rotate_
z - Builds a rotation 4 * 4 matrix around the Z axis and right-multiply it to
m
. - rotate_
z_ vec3 - Rotate a three dimensional vector around the
Z
axis. - rotate_
z_ vec4 - Rotate a three dimensional vector in homogeneous coordinates around the
Z
axis. - rotation
- A rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in radians.
- rotation2d
- A rotation 3 * 3 matrix created from an angle expressed in radians.
- round
- Component-wise rounding.
- row
- The
index
-th row of the matrixm
. - scale
- Builds a scale 4 * 4 matrix created from 3 scalars and right-multiply it to
m
. - scale2d
- Builds a 2D scaling matrix and right-multiply it to
m
. - scale_
bias - Builds a scale-bias matrix, and right-multiply it to
m
. - scale_
bias_ matrix - Builds a scale-bias matrix.
- scaling
- A 4 * 4 scale matrix created from a vector of 3 components.
- scaling2d
- A 3 * 3 scale matrix created from a vector of 2 components.
- set_
column - Sets to
x
theindex
-th column of the matrixm
. - set_row
- Sets to
x
theindex
-th row of the matrixm
. - shear2d_
x - Transforms a matrix with a shearing on X axis.
- shear2d_
y - Transforms a matrix with a shearing on Y axis.
- shear_x
- Transforms a matrix with a shearing on Y axis.
- shear_y
- Transforms a matrix with a shearing on Y axis.
- shear_z
- Transforms a matrix with a shearing on Z axis.
- sign
- For each vector component
x
: 1 ifx > 0
, 0 ifx == 0
, or -1 ifx < 0
. - sin
- Component-wise sinus.
- sinh
- Component-wise hyperbolic sinus.
- slerp
- Computes a spherical linear interpolation between the vectors
x
andy
assumed to be normalized. - smoothstep
- Returns 0.0 if
x <= edge0
and1.0 if x >= edge1
and performs smooth Hermite interpolation between 0 and 1 whenedge0 < x < edge1
. - sqrt
- Component-wise square root.
- step
- Returns 0.0 if
x[i] < edge
, otherwise it returns 1.0. - step_
scalar - Returns 0.0 if
x < edge
, otherwise it returns 1.0. - step_
vec - Returns 0.0 if
x[i] < edge[i]
, otherwise it returns 1.0. - tan
- Component-wise tangent.
- tanh
- Component-wise hyperbolic tangent.
- third
- Returns
1 / 3
. - three_
over_ two_ pi - Returns
3 / (2pi)
. - to_quat
- Converts a rotation matrix in homogeneous coordinates to a quaternion.
- translate
- Builds a translation 4 * 4 matrix created from a vector of 3 components and right-multiply it to
m
. - translate2d
- Builds a translation matrix and right-multiply it to
m
. - translation
- A 4 * 4 translation matrix created from the scaling factor on each axis.
- translation2d
- A 3 * 3 translation matrix created from the scaling factor on each axis.
- transpose
- The transpose of the matrix
m
. - triangle_
normal - The normal vector of the given triangle.
- trunc
- Returns a value equal to the nearest integer to
x
whose absolute value is not larger than the absolute value ofx
. - try_
convert - Attempts to convert an object to a more specific one.
- try_
convert_ ref - Attempts to convert an object to a more specific one.
- two_
over_ pi - Returns
2 / pi
. - two_
over_ root_ pi - Returns
2 / sqrt(pi)
. - two_pi
- Returns
2pi
. - two_
thirds - Returns
2 / 3
. - uint_
bits_ to_ float - For each component of
v
, returns a floating-point value corresponding to a unsigned integer encoding of a floating-point value. - uint_
bits_ to_ float_ scalar - Returns a floating-point value corresponding to a unsigned integer encoding of a floating-point value.
- unproject
- Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using a depth range of -1 to 1
- unproject_
no - Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
- unproject_
zo - Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
- value_
ptr - Converts a matrix or vector to a slice arranged in column-major order.
- value_
ptr_ mut - Converts a matrix or vector to a mutable slice arranged in column-major order.
- vec1
- Creates a new 1D vector.
- vec2
- Creates a new 2D vector.
- vec3
- Creates a new 3D vector.
- vec4
- Creates a new 4D vector.
- vec1_
to_ vec2 - Creates a 2D vector from another vector.
- vec1_
to_ vec3 - Creates a 3D vector from another vector.
- vec1_
to_ vec4 - Creates a 4D vector from another vector.
- vec2_
to_ vec1 - Creates a 1D vector from another vector.
- vec2_
to_ vec2 - Creates a 2D vector from another vector.
- vec2_
to_ vec3 - Creates a 3D vector from another vector.
- vec2_
to_ vec4 - Creates a 4D vector from another vector.
- vec3_
to_ vec1 - Creates a 1D vector from another vector.
- vec3_
to_ vec2 - Creates a 2D vector from another vector.
- vec3_
to_ vec3 - Creates a 3D vector from another vector.
- vec3_
to_ vec4 - Creates a 4D vector from another vector.
- vec4_
to_ vec1 - Creates a 1D vector from another vector.
- vec4_
to_ vec2 - Creates a 2D vector from another vector.
- vec4_
to_ vec3 - Creates a 3D vector from another vector.
- vec4_
to_ vec4 - Creates a 4D vector from another vector.
- zero
- Returns
0
. Gets the additive identity element.
Type Aliases§
- BVec1
- A 1D vector with boolean components.
- BVec2
- A 2D vector with boolean components.
- BVec3
- A 3D vector with boolean components.
- BVec4
- A 4D vector with boolean components.
- DMat2
- A 2x2 matrix with components of type
T
. - DMat3
- A 3x3 matrix with
f64
components. - DMat4
- A 4x4 matrix with
f64
components. - DMat2x2
- A 2x2 matrix with
f64
components. - DMat2x3
- A 2x3 matrix with
f64
components. - DMat2x4
- A 2x4 matrix with
f64
components. - DMat3x2
- A 3x2 matrix with
f64
components. - DMat3x3
- A 3x3 matrix with
f64
components. - DMat3x4
- A 3x4 matrix with
f64
components. - DMat4x2
- A 4x2 matrix with
f64
components. - DMat4x3
- A 4x3 matrix with
f64
components. - DMat4x4
- A 4x4 matrix with
f64
components. - DQuat
- A quaternion with f64 components.
- DVec1
- A 1D vector with
f64
components. - DVec2
- A 2D vector with
f64
components. - DVec3
- A 3D vector with
f64
components. - DVec4
- A 4D vector with
f64
components. - I8Vec1
- A 1D vector with
i8
components. - I8Vec2
- A 2D vector with
i8
components. - I8Vec3
- A 3D vector with
i8
components. - I8Vec4
- A 4D vector with
i8
components. - I16Vec1
- A 1D vector with
i16
components. - I16Vec2
- A 2D vector with
i16
components. - I16Vec3
- A 3D vector with
i16
components. - I16Vec4
- A 4D vector with
i16
components. - I32Vec1
- A 1D vector with
i32
components. - I32Vec2
- A 2D vector with
i32
components. - I32Vec3
- A 3D vector with
i32
components. - I32Vec4
- A 4D vector with
i32
components. - I64Vec1
- A 1D vector with
i64
components. - I64Vec2
- A 2D vector with
i64
components. - I64Vec3
- A 3D vector with
i64
components. - I64Vec4
- A 4D vector with
i64
components. - IVec1
- A 1D vector with
i32
components. - IVec2
- A 2D vector with
i32
components. - IVec3
- A 3D vector with
i32
components. - IVec4
- A 4D vector with
i32
components. - Mat2
- A 2x2 matrix with
f32
components. - Mat3
- A 3x3 matrix with
f32
components. - Mat4
- A 4x4 matrix with
f32
components. - Mat2x2
- A 2x2 matrix with
f32
components. - Mat2x3
- A 2x3 matrix with
f32
components. - Mat2x4
- A 2x4 matrix with
f32
components. - Mat3x2
- A 3x2 matrix with
f32
components. - Mat3x3
- A 3x3 matrix with
f32
components. - Mat3x4
- A 3x4 matrix with
f32
components. - Mat4x2
- A 4x2 matrix with
f32
components. - Mat4x3
- A 4x3 matrix with
f32
components. - Mat4x4
- A 4x4 matrix with
f32
components. - Qua
- A quaternion with components of type
T
. - Quat
- A quaternion with f32 components.
- TMat
- A matrix with components of type
T
. It hasR
rows, andC
columns. - TMat2
- A 2x2 matrix with components of type
T
. - TMat3
- A 3x3 matrix with components of type
T
. - TMat4
- A 4x4 matrix with components of type
T
. - TMat2x2
- A 2x2 matrix with components of type
T
. - TMat2x3
- A 2x3 matrix with components of type
T
. - TMat2x4
- A 2x4 matrix with components of type
T
. - TMat3x2
- A 3x2 matrix with components of type
T
. - TMat3x3
- A 3x3 matrix with components of type
T
. - TMat3x4
- A 3x4 matrix with components of type
T
. - TMat4x2
- A 4x2 matrix with components of type
T
. - TMat4x3
- A 4x3 matrix with components of type
T
. - TMat4x4
- A 4x4 matrix with components of type
T
. - TVec
- A column vector with components of type
T
. It hasD
rows (and one column). - TVec1
- A 1D vector with components of type
T
. - TVec2
- A 2D vector with components of type
T
. - TVec3
- A 3D vector with components of type
T
. - TVec4
- A 4D vector with components of type
T
. - U1
- U2
- U3
- U4
- U8Vec1
- A 1D vector with
u8
components. - U8Vec2
- A 2D vector with
u8
components. - U8Vec3
- A 3D vector with
u8
components. - U8Vec4
- A 4D vector with
u8
components. - U16Vec1
- A 1D vector with
u16
components. - U16Vec2
- A 2D vector with
u16
components. - U16Vec3
- A 3D vector with
u16
components. - U16Vec4
- A 4D vector with
u16
components. - U32Vec1
- A 1D vector with
u32
components. - U32Vec2
- A 2D vector with
u32
components. - U32Vec3
- A 3D vector with
u32
components. - U32Vec4
- A 4D vector with
u32
components. - U64Vec1
- A 1D vector with
u64
components. - U64Vec2
- A 2D vector with
u64
components. - U64Vec3
- A 3D vector with
u64
components. - U64Vec4
- A 4D vector with
u64
components. - UVec1
- A 1D vector with
u32
components. - UVec2
- A 2D vector with
u32
components. - UVec3
- A 3D vector with
u32
components. - UVec4
- A 4D vector with
u32
components. - Vec1
- A 1D vector with
f32
components. - Vec2
- A 2D vector with
f32
components. - Vec3
- A 3D vector with
f32
components. - Vec4
- A 4D vector with
f32
components.