Crate nalgebra_glm
source ·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§
- An allocator based on
ArrayStorage
andVecStorage
for statically-sized and dynamically-sized matrices respectively.
Constants§
- The constant dimension 1.
- The constant dimension 2 .
- The constant dimension 3 .
- The constant dimension 4 .
Traits§
- A number that can either be an integer or a float.
- A number that can be any float type.
- The basic scalar type for all structures of
nalgebra
.
Functions§
- For each matrix or vector component
x
ifx >= 0
; otherwise, it returns-x
. - Component-wise arc-cosinus.
- Component-wise hyperbolic arc-cosinus.
- Fast matrix inverse for affine matrix.
- Checks that all the vector components are
true
. - The angle between two vectors.
- Checks that at least one of the vector components is
true
. - Returns
true
if two vectors are collinear (up to an epsilon). - Returns
true
if two 2D vectors are collinear (up to an epsilon). - Returns
true
if two vectors are orthogonal (up to an epsilon). - Component-wise arc-sinus.
- Component-wise hyperbolic arc-sinus.
- Component-wise arc-tangent.
- Component-wise arc-tangent of
y / x
. - Component-wise hyperbolic arc-tangent.
- For each matrix or vector component returns a value equal to the nearest integer that is greater than or equal to
x
. - Returns
min(max(x[i], min_val), max_val)
for each component inx
using the valuesmin_val and
max_val` as bounds. - Returns
min(max(x, min_val), max_val)
. - Returns
min(max(x[i], min_val[i]), max_val[i])
for each component inx
using the components ofmin_val
andmax_val
as bounds. - The
index
-th column of the matrixm
. - The sum of every component of the given matrix or vector.
- The maximum of every component of the given matrix or vector.
- The minimum of every component of the given matrix or vector.
- The product of every component of the given matrix or vector.
- Converts an object from one type to an equivalent or more general one.
- Converts an object from one type to an equivalent or more general one.
- Use with care! Same as
try_convert()
but without any property checks. - Use with care! Same as
try_convert()
but without any property checks. - Component-wise cosinus.
- Component-wise hyperbolic cosinus.
- The cross product of two vectors.
- The 2D perpendicular product between two vectors.
- Component-wise conversion from radians to degrees.
- The determinant of the matrix
m
. - Builds a 2x2 diagonal matrix.
- Builds a 2x3 diagonal matrix.
- Builds a 2x4 diagonal matrix.
- Builds a 3x2 diagonal matrix.
- Builds a 3x3 diagonal matrix.
- Builds a 3x4 diagonal matrix.
- Builds a 4x2 diagonal matrix.
- Builds a 4x3 diagonal matrix.
- Builds a 4x4 diagonal matrix.
- The distance between two points.
- The squared distance between two points.
- The dot product of two vectors.
- The Euler constant.
- Default epsilon value used for approximate comparison.
- Component-wise equality comparison.
- Perform a component-wise equal-to comparison of two matrices.
- Returns the component-wise comparison of
|x - y| < epsilon
. - Returns the component-wise comparison on each matrix column
|x - y| < epsilon
. - Component-wise approximate equality of two vectors, using a scalar epsilon.
- Component-wise approximate equality of two vectors, using a per-component epsilon.
- The Euler constant.
- Component-wise exponential.
- Component-wise base-2 exponential.
- If
dot(nref, i) < 0.0
, returnn
, otherwise, return-n
. - The dot product of the normalized version of
x
andy
. - Returns a signed integer value representing the encoding of a floating-point value.
- Returns a signed integer value representing the encoding of each component of
v
. - Returns an unsigned integer value representing the encoding of a floating-point value.
- Returns an unsigned integer value representing the encoding of each component of
v
. - Returns componentwise a value equal to the nearest integer that is less then or equal to
x
. - Returns
4 / pi
. - Returns the fractional part of each component of
x
. - Returns the golden ratio.
- Component-wise
>
comparison. - Component-wise
>=
comparison. - Returns
pi / 2
. - The identity matrix.
- Build infinite right-handed perspective projection matrix with [-1,1] depth range.
- Build infinite right-handed perspective projection matrix with [0,1] depth range.
- Returns a floating-point value corresponding to a signed integer encoding of a floating-point value.
- For each components of
v
, returns a floating-point value corresponding to a signed integer encoding of a floating-point value. - The inverse of the matrix
m
. - Compute the transpose of the inverse of a matrix.
- Compute the inverse of the square root of each component of
v
. - Returns
true
if all the components ofv
are zero (up to an epsilon). - Returns
true
ifv
has a magnitude of 1 (up to an epsilon). - Returns
true
ifv
is zero (up to an epsilon). - The l1-norm of
x - y
. - The l1-norm of
v
. - The l2-norm of
x - y
. - The l2-norm of
v
. - Returns
true
if{a, b, c}
forms a left-handed trihedron. - The magnitude of a vector.
- The squared magnitude of
x
. - Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the vectors x and y using the scalar value a. - Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the scalars x and y using the scalar value a. - Returns
x * (1.0 - a) + y * a
, i.e., the component-wise linear blend ofx
andy
using the components of the vectora
as coefficients. - Component-wise
<
comparison. - Component-wise
<=
comparison. - Returns
ln(ln(2))
. - Returns
ln(10)
. - Returns
ln(2)
. - Component-wise logarithm.
- Component-wise base-2 logarithm.
- Build a look at view matrix based on the right handedness.
- Build a left handed look at view matrix.
- Build a right handed look at view matrix.
- The magnitude of a vector.
- The squared magnitude of
x
. - Creates a 2x2 matrix from a slice arranged in column-major order.
- Creates a 2x2 matrix from a slice arranged in column-major order.
- Creates a 2x3 matrix from a slice arranged in column-major order.
- Creates a 2x4 matrix from a slice arranged in column-major order.
- Creates a 3 matrix from a slice arranged in column-major order.
- Creates a 3x2 matrix from a slice arranged in column-major order.
- Creates a 3x3 matrix from a slice arranged in column-major order.
- Creates a 3x4 matrix from a slice arranged in column-major order.
- Creates a 4x4 matrix from a slice arranged in column-major order.
- Creates a 4x2 matrix from a slice arranged in column-major order.
- Creates a 4x3 matrix from a slice arranged in column-major order.
- Creates a 4x4 matrix from a slice arranged in column-major order.
- Creates a quaternion from a slice arranged as
[x, y, z, w]
. - Creates a 1D vector from a slice.
- Creates a 2D vector from a slice.
- Creates a 3D vector from another vector.
- Creates a 4D vector from another vector.
- Create a new 2x2 matrix.
- Converts a 2x2 matrix to a 3x3 matrix.
- Converts a 2x2 matrix to a 4x4 matrix.
- Create a new 2x2 matrix.
- Create a new 2x3 matrix.
- Create a new 2x4 matrix.
- Create a new 3x3 matrix.
- Converts a 3x3 matrix to a 2x2 matrix.
- Converts a 3x3 matrix to a 4x4 matrix.
- Converts a rotation matrix to a quaternion.
- Create a new 3x2 matrix.
- Create a new 3x3 matrix.
- Create a new 3x4 matrix.
- Create a new 4x4 matrix.
- Converts a 4x4 matrix to a 2x2 matrix.
- Converts a 4x4 matrix to a 3x3 matrix.
- Create a new 4x2 matrix.
- Create a new 4x3 matrix.
- Create a new 4x4 matrix.
- Component-wise multiplication of two matrices.
- Builds a 4x4 matrix
m
such that for anyv
:m * v == cross(x, v)
. - Builds a 3x3 matrix
m
such that for anyv
:m * v == cross(x, v)
. - Component-wise maximum between a vector and a scalar.
- Component-wise maximum between two vectors.
- Returns the maximum among two values.
- Component-wise maximum between three vectors.
- Returns the maximum among three values.
- Component-wise maximum between four vectors.
- Returns the maximum among four values.
- Component-wise minimum between a vector and a scalar.
- Component-wise minimum between two vectors.
- Returns the maximum among two values.
- Component-wise minimum between three vectors.
- Returns the minimum among three values.
- Component-wise minimum between four vectors.
- Returns the minimum among four values.
- Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the vectors x and y using the scalar value a. - Returns
x * (1.0 - a) + y * a
, i.e., the linear blend of the scalars x and y using the scalar value a. - Returns
x * (1.0 - a) + y * a
, i.e., the component-wise linear blend ofx
andy
using the components of the vectora
as coefficients. - Modulus between two values.
- Component-wise modulus.
- Normalizes a vector.
- The dot product of the normalized version of
x
andy
. - Component-wise not
!
. - Component-wise not-equality
!=
. - Perform a component-wise not-equal-to comparison of two matrices.
- Returns the component-wise comparison of
|x - y| < epsilon
. - Returns the component-wise comparison of
|x - y| >= epsilon
. - Component-wise approximate non-equality of two vectors, using a scalar epsilon.
- Component-wise approximate non-equality of two vectors, using a per-component epsilon.
- Returns
1
. Gets the multiplicative identity element. - Returns
1 / pi
. - Returns
1 / sqrt(2)
. - Returns
1 / (2pi)
. - Build the rotation matrix needed to align
normal
andup
. - Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- Creates a left hand matrix for a orthographic-view frustum with a depth range of -1 to 1
- Creates a left hand matrix for a orthographic-view frustum with a depth range of -1 to 1
- Creates a matrix for a left hand orthographic-view frustum with a depth range of 0 to 1
- Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand orthographic-view frustum with a depth range of -1 to 1
- Creates a right hand matrix for a orthographic-view frustum with a depth range of 0 to 1
- Creates a right hand matrix for a orthographic-view frustum with a depth range of 0 to 1
- 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
. - Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a left hand perspective-view frustum with a depth range of 0 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a left hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a left hand perspective-view frustum with a depth range of 0 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of -1 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- Creates a matrix for a right hand perspective-view frustum with a depth range of 0 to 1
- The value of PI.
- Define a picking region.
- Component-wise power.
- Build planar projection matrix along normal axis, and right-multiply it to
m
. - Build planar projection matrix along normal axis and right-multiply it to
m
. - Map the specified object coordinates
(obj.x, obj.y, obj.z)
into window coordinates with a depth range of -1 to 1 - Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
- Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
- Returns
pi / 4
. - Creates a new quaternion.
- The rotation angle of this quaternion assumed to be normalized.
- Creates a quaternion from an axis and an angle.
- The rotation axis of a quaternion assumed to be normalized.
- Convert a quaternion to a rotation matrix in homogeneous coordinates.
- The conjugate of
q
. - Multiplies two quaternions.
- Rotate the vector
v
by the quaternionq
assumed to be normalized. - The scalar product of two quaternions.
- Component-wise equality comparison between two quaternions.
- Component-wise approximate equality comparison between two quaternions.
- Euler angles of the quaternion
q
as (pitch, yaw, roll). - Computes the quaternion exponential.
- The quaternion
w
component. - Normalized linear interpolation between two quaternions.
- Component-wise
>
comparison between two quaternions. - Component-wise
>=
comparison between two quaternions. - The quaternion representing the identity rotation.
- Rotate the vector
v
by the inverse of the quaternionq
assumed to be normalized. - The inverse of
q
. - The magnitude of the quaternion
q
. - The squared magnitude of a quaternion
q
. - Interpolate linearly between
x
andy
. - Component-wise
<
comparison between two quaternions. - Component-wise
<=
comparison between two quaternions. - Computes the quaternion logarithm.
- Computes a right hand look-at quaternion
- Computes a left-handed look-at quaternion (equivalent to a left-handed look-at matrix).
- Computes a right-handed look-at quaternion (equivalent to a right-handed look-at matrix).
- The magnitude of the quaternion
q
. - The squared magnitude of a quaternion
q
. - Normalizes the quaternion
q
. - Component-wise non-equality comparison between two quaternions.
- Component-wise approximate non-equality comparison between two quaternions.
- The “pitch” Euler angle of the quaternion
x
assumed to be normalized. - Raises the quaternion
q
to the powery
. - The “roll” Euler angle of the quaternion
x
assumed to be normalized. - Builds a quaternion from an axis and an angle, and right-multiply it to the quaternion
q
. - Rotates a quaternion from a vector of 3 components normalized axis and an angle.
- Rotates a vector in homogeneous coordinates by a quaternion assumed to be normalized.
- Rotates a vector by a quaternion assumed to be normalized.
- The rotation required to align
orig
todest
. - The spherical linear interpolation between two quaternions.
- Interpolate spherically between
x
andy
. - Converts a quaternion to a rotation matrix.
- Converts a quaternion to a rotation matrix in homogeneous coordinates.
- The “yaw” Euler angle of the quaternion
x
assumed to be normalized. - Component-wise conversion from degrees to radians.
- Builds a reflection matrix, and right-multiply it to
m
. - Builds a reflection matrix and right-multiply it to
m
. - For the incident vector
i
and surface orientationn
, returns the reflection direction :result = i - 2.0 * dot(n, i) * n
. - For the incident vector
i
and surface normaln
, and the ratio of indices of refractioneta
, return the refraction vector. - Build an infinite perspective projection matrix with a reversed [0, 1] depth range.
- Creates a matrix for a right hand perspective-view frustum with a reversed depth range of 0 to 1.
- Returns
true
if{a, b, c}
forms a right-handed trihedron. - Returns
sqrt(5)
. - Returns
sqrt(pi / 2)
. - Returns
sqrt(ln(4))
. - Returns the square root of pi.
- Returns the square root of 3.
- Returns the square root of 2.
- Returns the square root of 2pi.
- Builds a rotation 4 * 4 matrix created from an axis vector and an angle and right-multiply it to
m
. - Builds a 2D rotation matrix from an angle and right-multiply it to
m
. - Builds a rotation 4 * 4 matrix created from a normalized axis and an angle.
- Rotate a two dimensional vector.
- Rotate a three dimensional vector around an axis.
- Rotate a thee dimensional vector in homogeneous coordinates around an axis.
- Builds a rotation 4 * 4 matrix around the X axis and right-multiply it to
m
. - Rotate a three dimensional vector around the
X
axis. - Rotate a three dimensional vector in homogeneous coordinates around the
X
axis. - Builds a rotation 4 * 4 matrix around the Y axis and right-multiply it to
m
. - Rotate a three dimensional vector around the
Y
axis. - Rotate a three dimensional vector in homogeneous coordinates around the
Y
axis. - Builds a rotation 4 * 4 matrix around the Z axis and right-multiply it to
m
. - Rotate a three dimensional vector around the
Z
axis. - Rotate a three dimensional vector in homogeneous coordinates around the
Z
axis. - A rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in radians.
- A rotation 3 * 3 matrix created from an angle expressed in radians.
- Component-wise rounding.
- The
index
-th row of the matrixm
. - Builds a scale 4 * 4 matrix created from 3 scalars and right-multiply it to
m
. - Builds a 2D scaling matrix and right-multiply it to
m
. - Builds a scale-bias matrix, and right-multiply it to
m
. - Builds a scale-bias matrix.
- A 4 * 4 scale matrix created from a vector of 3 components.
- A 3 * 3 scale matrix created from a vector of 2 components.
- Sets to
x
theindex
-th column of the matrixm
. - Sets to
x
theindex
-th row of the matrixm
. - Transforms a matrix with a shearing on X axis.
- Transforms a matrix with a shearing on Y axis.
- Transforms a matrix with a shearing on Y axis.
- Transforms a matrix with a shearing on Y axis.
- Transforms a matrix with a shearing on Z axis.
- For each vector component
x
: 1 ifx > 0
, 0 ifx == 0
, or -1 ifx < 0
. - Component-wise sinus.
- Component-wise hyperbolic sinus.
- Computes a spherical linear interpolation between the vectors
x
andy
assumed to be normalized. - Returns 0.0 if
x <= edge0
and1.0 if x >= edge1
and performs smooth Hermite interpolation between 0 and 1 whenedge0 < x < edge1
. - Component-wise square root.
- Returns 0.0 if
x[i] < edge
, otherwise it returns 1.0. - Returns 0.0 if
x < edge
, otherwise it returns 1.0. - Returns 0.0 if
x[i] < edge[i]
, otherwise it returns 1.0. - Component-wise tangent.
- Component-wise hyperbolic tangent.
- Returns
1 / 3
. - Returns
3 / (2pi)
. - Converts a rotation matrix in homogeneous coordinates to a quaternion.
- Builds a translation 4 * 4 matrix created from a vector of 3 components and right-multiply it to
m
. - Builds a translation matrix and right-multiply it to
m
. - A 4 * 4 translation matrix created from the scaling factor on each axis.
- A 3 * 3 translation matrix created from the scaling factor on each axis.
- The transpose of the matrix
m
. - The normal vector of the given triangle.
- Returns a value equal to the nearest integer to
x
whose absolute value is not larger than the absolute value ofx
. - Attempts to convert an object to a more specific one.
- Attempts to convert an object to a more specific one.
- Returns
2 / pi
. - Returns
2 / sqrt(pi)
. - Returns
2pi
. - Returns
2 / 3
. - For each component of
v
, returns a floating-point value corresponding to a unsigned integer encoding of a floating-point value. - Returns a floating-point value corresponding to a unsigned integer encoding of a floating-point value.
- Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using a depth range of -1 to 1
- Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
- Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
- Converts a matrix or vector to a slice arranged in column-major order.
- Converts a matrix or vector to a mutable slice arranged in column-major order.
- Creates a new 1D vector.
- Creates a 2D vector from another vector.
- Creates a 3D vector from another vector.
- Creates a 4D vector from another vector.
- Creates a new 2D vector.
- Creates a 1D vector from another vector.
- Creates a 2D vector from another vector.
- Creates a 3D vector from another vector.
- Creates a 4D vector from another vector.
- Creates a new 3D vector.
- Creates a 1D vector from another vector.
- Creates a 2D vector from another vector.
- Creates a 3D vector from another vector.
- Creates a 4D vector from another vector.
- Creates a new 4D vector.
- Creates a 1D vector from another vector.
- Creates a 2D vector from another vector.
- Creates a 3D vector from another vector.
- Creates a 4D vector from another vector.
- Returns
0
. Gets the additive identity element.
Type Aliases§
- A 1D vector with boolean components.
- A 2D vector with boolean components.
- A 3D vector with boolean components.
- A 4D vector with boolean components.
- A 2x2 matrix with components of type
T
. - A 2x2 matrix with
f64
components. - A 2x3 matrix with
f64
components. - A 2x4 matrix with
f64
components. - A 3x3 matrix with
f64
components. - A 3x2 matrix with
f64
components. - A 3x3 matrix with
f64
components. - A 3x4 matrix with
f64
components. - A 4x4 matrix with
f64
components. - A 4x2 matrix with
f64
components. - A 4x3 matrix with
f64
components. - A 4x4 matrix with
f64
components. - A quaternion with f64 components.
- A 1D vector with
f64
components. - A 2D vector with
f64
components. - A 3D vector with
f64
components. - A 4D vector with
f64
components. - A 1D vector with
i8
components. - A 2D vector with
i8
components. - A 3D vector with
i8
components. - A 4D vector with
i8
components. - A 1D vector with
i16
components. - A 2D vector with
i16
components. - A 3D vector with
i16
components. - A 4D vector with
i16
components. - A 1D vector with
i32
components. - A 2D vector with
i32
components. - A 3D vector with
i32
components. - A 4D vector with
i32
components. - A 1D vector with
i64
components. - A 2D vector with
i64
components. - A 3D vector with
i64
components. - A 4D vector with
i64
components. - A 1D vector with
i32
components. - A 2D vector with
i32
components. - A 3D vector with
i32
components. - A 4D vector with
i32
components. - A 2x2 matrix with
f32
components. - A 2x2 matrix with
f32
components. - A 2x3 matrix with
f32
components. - A 2x4 matrix with
f32
components. - A 3x3 matrix with
f32
components. - A 3x2 matrix with
f32
components. - A 3x3 matrix with
f32
components. - A 3x4 matrix with
f32
components. - A 4x4 matrix with
f32
components. - A 4x2 matrix with
f32
components. - A 4x3 matrix with
f32
components. - A 4x4 matrix with
f32
components. - A quaternion with components of type
T
. - A quaternion with f32 components.
- A matrix with components of type
T
. It hasR
rows, andC
columns. - A 2x2 matrix with components of type
T
. - A 2x2 matrix with components of type
T
. - A 2x3 matrix with components of type
T
. - A 2x4 matrix with components of type
T
. - A 3x3 matrix with components of type
T
. - A 3x2 matrix with components of type
T
. - A 3x3 matrix with components of type
T
. - A 3x4 matrix with components of type
T
. - A 4x4 matrix with components of type
T
. - A 4x2 matrix with components of type
T
. - A 4x3 matrix with components of type
T
. - A 4x4 matrix with components of type
T
. - A column vector with components of type
T
. It hasD
rows (and one column). - A 1D vector with components of type
T
. - A 2D vector with components of type
T
. - A 3D vector with components of type
T
. - A 4D vector with components of type
T
. - A 1D vector with
u8
components. - A 2D vector with
u8
components. - A 3D vector with
u8
components. - A 4D vector with
u8
components. - A 1D vector with
u16
components. - A 2D vector with
u16
components. - A 3D vector with
u16
components. - A 4D vector with
u16
components. - A 1D vector with
u32
components. - A 2D vector with
u32
components. - A 3D vector with
u32
components. - A 4D vector with
u32
components. - A 1D vector with
u64
components. - A 2D vector with
u64
components. - A 3D vector with
u64
components. - A 4D vector with
u64
components. - A 1D vector with
u32
components. - A 2D vector with
u32
components. - A 3D vector with
u32
components. - A 4D vector with
u32
components. - A 1D vector with
f32
components. - A 2D vector with
f32
components. - A 3D vector with
f32
components. - A 4D vector with
f32
components.