[][src]Crate nalgebra_glm

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.1"

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 and TVec instead of mat and vec.
  • 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 while glm::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 example Vec3::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 example glm::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 to glm::vec2(v.x, v.x) and to Vec2::new(v.x, v.x).
  • v.zx() is equivalent to glm::vec2(v.z, v.x) and to Vec2::new(v.z, v.x).
  • v.yxz() is equivalent to glm::vec3(v.y, v.x, v.z) and to Vec3::new(v.y, v.x, v.z).
  • v.zzy() is equivalent to glm::vec3(v.z, v.z, v.y) and to Vec3::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 of type1 into an instance of type2. For example glm::mat3_to_mat4(m) will convert the 3x3 matrix m 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, or convert_unchecked functions. These functions are directly re-exported from nalgebra and are extremely versatile:
    1. The convert function can convert any type (especially geometric types from nalgebra like Isometry3) into another algebraic type which is equivalent but more general. For example, let sim: Similarity3<_> = na::convert(isometry) will convert an Isometry3 into a Similarity3. In addition, let mat: Mat4 = glm::convert(isometry) will convert an Isometry3 to a 4x4 matrix. This will also convert the scalar types, therefore: let mat: DMat4 = glm::convert(m) where m: Mat4 will work. However, conversion will not work the other way round: you can't convert a Matrix4 to an Isometry3 using glm::convert because that could cause unexpected results if the matrix does not complies to the requirements of the isometry.
    2. 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 return None if the requirements are not satisfied.
    3. 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 by nalgebra-glm and specific transformation types from nalgebra like Isometry3. Just be careful you know your conversions make sense.

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

DefaultAllocator

An allocator based on GenericArray and MatrixVec for statically-sized and dynamically-sized matrices respectively.

U1

A type level dimension with a value of 1.

U2

A type level dimension.

U3

A type level dimension.

U4

A type level dimension.

Traits

Dimension

A type-level number representing a vector, matrix row, or matrix column, dimension.

Number

A number that can either be an integer or a float.

Real

Trait shared by all reals.

Scalar

The basic scalar type for all structures of nalgebra.

Functions

abs

For each matrix or vector component x if x >= 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 in x using the values min_val andmax_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 in x using the components of min_val and max_val as bounds.

column

The index-th column of the matrix m.

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, return n, otherwise, return -n.

fast_normalize_dot

The dot product of the normalized version of x and y.

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.

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 of v are zero (up to an epsilon).

is_normalized

Returns true if v has a magnitude of 1 (up to an epsilon).

is_null

Returns true if v 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 of x and y using the components of the vector a 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.

mat3_to_quat

Converts a rotation matrix to a quaternion.

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.

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 any v: m * v == cross(x, v).

matrix_cross3

Builds a 3x3 matrix m such that for any v: 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.

max3_scalar

Returns the maximum among three values.

max4

Component-wise maximum between four vectors.

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.

min3_scalar

Returns the minimum among three values.

min4

Component-wise minimum between four vectors.

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 of x and y using the components of the vector a 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 and y.

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

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 and up.

ortho

Creates a matrix for an orthographic parallel viewing volume, using the right handedness and OpenGL near and far clip planes definition.

outer_product

Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r.

perspective

Creates a matrix for a perspective-view frustum based on the right handedness and OpenGL near and far clip planes definition.

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 using OpenGL near and far clip planes definition.

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 quaternion q 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 quaternion q 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 and y.

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-handed look-at quaternion (equivalent to a right-handed look-at matrix).

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 power y.

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 to dest.

quat_short_mix

The spherical linear interpolation between two quaternions.

quat_slerp

Interpolate spherically between x and y.

quat_to_mat3

Converts a quaternion to a rotation matrix.

quat_to_mat4

Converts a quaternion to a rotation matrix in homogenous coordinates.

quat_yaw

The "yaw" Euler angle of the quaternion x assumed to be normalized.

radians

Component-wise conversion fro 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 orientation n, returns the reflection direction : result = i - 2.0 * dot(n, i) * n.

refract_vec

For the incident vector i and surface normal n, and the ratio of indices of refraction eta, return the refraction vector.

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 matrix m.

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 the index-th column of the matrix m.

set_row

Sets to x the index-th row of the matrix m.

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 if x > 0, 0 if x == 0, or -1 if x < 0.

sin

Component-wise sinus.

sinh

Component-wise hyperbolic sinus.

slerp

Computes a spherical linear interpolation between the vectors x and y assumed to be normalized.

smoothstep

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < 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 of x.

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 OpenGL near and far clip planes definition.

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

Gets the additive identity element.

Type Definitions

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 N.

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.

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.

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.

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 2x2 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 N.

Quat

A quaternion with f32 components.

TMat

A matrix with components of type N. It has R rows, and C columns.

TMat2

A 2x2 matrix with components of type N.

TMat3

A 3x3 matrix with components of type N.

TMat4

A 4x4 matrix with components of type N.

TMat2x2

A 2x2 matrix with components of type N.

TMat2x3

A 2x3 matrix with components of type N.

TMat2x4

A 2x4 matrix with components of type N.

TMat3x2

A 3x2 matrix with components of type N.

TMat3x3

A 3x3 matrix with components of type N.

TMat3x4

A 3x4 matrix with components of type N.

TMat4x2

A 4x2 matrix with components of type N.

TMat4x3

A 4x3 matrix with components of type N.

TMat4x4

A 4x4 matrix with components of type N.

TVec

A column vector with components of type N. It has D rows (and one column).

TVec1

A 1D vector with components of type N.

TVec2

A 2D vector with components of type N.

TVec3

A 3D vector with components of type N.

TVec4

A 4D vector with components of type N.

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.

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.

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.