All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Added u32
implementation of BVec3A
and BVec4
when SIMD is not available. These are used instead of aliasing to the bool
implementations.
Removed Add
, Sub
, and scalar Mul
implementations from affine types as they didn't make sense on these types.
Removed deprecated const_*
macros. These have been replaced by const fn
methods.
Fixed neg
and signum
to consistently handle negative zero across multiple platforms.
Removed register_attr
feature usage for SPIR-V targets.
Added missing Serialize
, Deserialize
and PartialEq
implementations.
Added Sum<Self>
and Product<Self>
implementations for all vector, matrix and quaternion types.
Added 4x4 matrix methods look_at_lh
and look_at_rh
. These were previously private.
Added dot_into_vec
methods to vector which returns the result of the dot product splatted to all vector lanes.
Added is_negative_bitmask
to vector types which returns a u32
of bits for each negative vector lane.
Added splat
method and TRUE
and FALSE
constants to all BVec
types.
Added from_mat3a
methods to Affine2
, Mat2
, Mat4
and Quat
types.
Disable serde
default features.
Made to_cols_array
, to_cols_array_2d
, and from_diagonal
methods const fn
.
glam_assert
being too restrictive in matrix transform point and transform vector methods.core-simd
feature which enables SIMD support via the unstable core::simd
module.PartialEq
and Eq
instead of providing a trait implementation for all non SIMD types.Restore missing $crate::
prefix in deprecated const_*
macros.
Fixed some performance regressions in affine and matrix determinant and inverses due to lack of inlining.
Fixed some performance regressions in the SSE2 Vec3A
to Vec3
from conversion.
BitXor
and BitXorAssign
traits for bool
vectors.Minimum Supported Version of Rust bumped to 1.58.1 to allow const
pointer dereferences in constant evaluation.
The abs_diff_eq
method on Mat2
and DMat2
now takes other
by value instead of reference. This is consistent with the other matrix types.
The AsMut
and Deref
trait implementations on Quat
and DQuat
was removed. Quaternion fields are now public.
The AsRef
trait implementations were removed from BVec2
, BVec3
, BVec3A
, BVec4
and BVec4A
.
NEG_ONE
constant was added to all signed vector types.
NEG_X
, NEG_Y
, NEG_Z
and NEG_W
negative axis vectors were added to signed vector types.
The rotate
and from_angle
methods were added to Vec2
and DVec2
. from_angle
returns a 2D vector containing [angle.cos(), angle.sin()]
that can be used to rotate
another 2D vector.
The from_array
const
function was added to all vector types.
Source code is now largely generated. This removes most usage of macros internally to improve readability. There should be no change in API or behavior other than what is documented here.
Many methods have been made const fn
:
new
, splat
, from_slice
, to_array
and extend
on vector typesfrom_cols
, from_cols_array
, from_cols_array_2d
, from_cols_slice
on matrix typesfrom_xyzw
and from_array
on quaternion typesfrom_cols
on affine typesThe const
new macros where deprecated.
TransformRT
and TransformSRT
types.max_element
method where the w
element check was incorrect.slerp
with a rotation of tau.to_array()
to Quat
and DQuat
.mul_add
method to all vector types - note that this will be slower without hardware support enabled.fast-math
flag which will sacrifice some float determinism for speed.sse2
and wasm32
implementations of Mat4::determinant()
.from_rotation_arc_2d()
method to Quat
and DQuat
which will return a rotation between two 2D vectors around the z axis.Neg
operator for matrix types.cuda
feature which forces glam
types to match cuda's alignment requirements.Quat
and DQuat
methods from_rotation_arc()
and from_rotation_arc_colinear()
are now available in no_std
.Vec3
and DVec3
methods any_orthogonal_vector()
, any_orthonormal_vector()
and any_orthonormal_pair()
are now available in no_std
.repr(C)
attribute to affine types.as_f32()
, as_f64()
, as_i32()
and as_u32()
methods.mint
crate.IntoMint
trait from the mint
crate.mint
conversions for Mat3A
.as_vec3a
cast methods to vector types.From
implementations. Use .truncate()
or swizzle methods instead.Not
, Shl
, Shr
, BitAnd
, BitOr
and BitXor
implementations for all IVec
and UVec
vector types.NAN
constant for all types.glam
's architecture.Sum
and Product
traits are now implemented in no_std
builds.wasm-bindgen-test
and rustdoc
alias
support.wasm32
SIMD intrinsics support.rkyv
serialization crate.Rem
and RemAssign
implementations for all vector types.xyz()
method for returning the vector part of the quaternion.From((Scalar, Vector3))
for 4D vector types.as_f32()
, as_f64()
, as_i32()
and as_u32()
methods in favor of more specific methods such as as_vec2()
, as_dvec2()
, as_ivec2()
and as_uvec2()
and so on.serde
support for Affine2
, DAffine2
, Affine3A
and DAffine3
.Add
and Sub
implementations of scalar values for vector types may create ambiguities with existing calls to add
and sub
.From<Mat3>
implementation for Mat2
and From<DMat3>
for DMat2
. These have been replaced by Mat2::from_mat3()
and DMat2::from_mat3()
.From<Mat4>
implementation for Mat3
and From<DMat4>
for DMat3
. These have been replaced by Mat3::from_mat4()
and DMat3::from_mat4()
.from_slice_unaligned()
, write_to_slice_unaligned()
, from_rotation_mat4
and from_rotation_ypr()
methods.col_mut()
method which returns a mutable reference to a matrix column to all matrix types.AddAssign
, MulAssign
and SubAssign
implementations for all matrix types.Add
and Sub
implementations of scalar values for vector types.glam_assert!
checks and documented methods where they are used.project_onto()
, project_onto_normalized()
, reject_from()
and reject_from_normalized()
.Mat2::from_mat3()
, DMat2::from_mat3()
, Mat3::from_mat4()
, DMat3::from_mat4()
which create a smaller matrix from a larger one, discarding a final row and column of the input matrix.Mat3::from_mat2()
, DMat3::from_mat2()
, Mat4::from_mat3()
and DMat4::from_mat3()
which create an affine transform from a smaller linear transform matrix.AsRef
and AsMut
on SPIR-V targets. Also removed SPIR-V support for some methods that used as_ref()
, including hash()
. Not a breaking change as these methods would not have worked anyway.sprirv-std
dependency was removed, rust-gpu depends on glam internally again for now.must_use
attribute to all inverse()
, normalize()
, try_normalize()
, transpose()
and conjugate()
methods.fract()
method to float vector types which return a vector containing self - self.floor()
.approx
crate. Note that all glam types implement their own abs_diff_eq()
method without requiring the approx
dependency.from_cols()
methods to affine types.from_cols_array()
, to_cols_array()
, from_cols_array_2d()
, to_cols_array_2d()
, from_cols_slice()
and write_cols_to_slice()
.core::fmt::Display
trait implementations for affine types.core::ops::Add
, core::ops::Mul
scalar and core::ops::Sub
trait implementations for affine types.from_array()
methods to quaternion types.from_slice_unaligned()
and write_to_slice_unaligned()
methods to from_slice()
and write_to_slice()
._mm_rcp_ps
from SSE2 implementation of Quat::slerp
as this instruction is not deterministic between Intel and AMD chips.const_assert_eq!
size and alignment checks for SPIR-V targets.PartialOrd
and Ord
trait implementations for all glam
types.zero()
, one()
, unit_x()
, unit_y()
, unit_z()
, unit_w()
, identity()
and Mat2::scale()
methods.Quat
From
trait conversions which would allow creating a non-uniform quaternion without necessarily realising, including from Vec4
, (x, y, z, w)
and [f32; 4]
.EulerRot
enum for specifying Euler rotation order and Quat::from_euler()
, Mat3::from_euler()
and Mat4::from_euler()
which support specifying a rotation order and angles of rotation.Quat::to_euler()
method for extracting Euler angles.Quat::from_vec4()
which is an explicit method for creating a quaternion from a 4D vector. The method does not normalize the resulting quaternion.Mat3A
type which uses Vec3A
columns. It is 16 byte aligned and contains internal padding but it generally faster than Mat3
for most operations if SIMD is available.Affine3A
and DAffine3
. These are more efficient than using Mat4
and DMat4
respectively when working with 3D affine transforms.Affine2
and DAffine2
. These are more efficient than using Mat3
and DMat3
respectively when working with 2D affine transforms.Quat::from_affine3()
to create a quaternion from an affine transform rotation.to_array()
method to vector types to better match the matrix methods.Quat::from_rotation_ypr()
, Mat3::from_rotation_ypr()
and Mat4::from_rotation_ypr()
in favor of new from_euler()
methods.Quat::from_rotation_mat3()
and Quat::from_rotation_mat4()
in favor of new from_mat3
and from_mat4
methods.TransformSRT
and TransformRT
which are under the transform-types
feature. These will be moved to a separate experimental crate.spirv-std
dependency version to 0.4.0-alpha7
.spirv-std
dependency.AXES[]
constants to all vector types. These are arrays containing the unit vector for each axis.from_scaled_axis
and to_scaled_axis
methods.bytemuck
to 1.5
, rand
to 0.8
, rand_xoshiro
to 0.6
and spirv-std
to 0.4.0-alpha4
.clamp()
functions.col()
and row()
.spirv-std
for the SPIR-V target.From
impls.transform_point3()
was changed to not perform the perspective divide. This is an optimization for use with affine transforms where perspective correction is not required. The project_point3()
method was added for transforming points by perspective projections.from_scale()
method was changed to create a affine transform containing a 2-dimensional non-uniform scale to be consistent with the 4x4 matrix version. The from_diagonal()
method can be used to create a 3x3 scale matrix.transform_point2_as_vec3a
, transform_vector2_as_vec3a
and mul_vec3_as_vec3a
were unintentionally pub
and are no longer publicly accessible.Vec2::X
, Vec4::W
etc constants as a shorter versions of unit_x()
and friends.ONE
constants for vectors.IDENTITY
constants for Mat2
, Mat3
, Mat4
and Quat
.ZERO
constant for vectors and matrices.clamp_length()
, clamp_length_max()
, and clamp_length_min
methods for f32
and f64
vector types.try_normalize()
and normalize_or_zero()
for all real vector types.from_diagonal()
methods to all matrix types for creating diagonal matrices from a vector.angle_between()
, from_rotation_arc()
and from_rotation_arc_colinear()
to quaternion types.inverse()
which assumes the quaternion is already normalized and returns the conjugate.from_translation()
and from_angle()
methods to 3x3 matrix types.project_point3()
method to 4x4 matrix types. This method is for transforming 3D vectors by perspective projection transforms.Eq
and Hash
impls for integer vector types.::unit_x/y/z()
, ::zero()
, ::one()
, ::identity()
functions in favor of constants.Vec2Mask
, Vec3Mask
and Vec4Mask
have been replaced by BVec2
, BVec3
, BVec3A
, BVec4
and BVec4A
. These types are used by some vector methods and are not typically referenced directly.f64
primitive type supportDVec2
, DVec3
and DVec4
DMat2
, DMat3
and DMat4
DQuat
i32
primitive type supportIVec2
, IVec3
and IVec4
u32
primitive type supportUVec2
, UVec3
and UVec4
bool
primitive type supportBVec2
, BVec3
and BVec4
build.rs
has been removed.Vec3
repr(simd)
for spirv
targets.From<(Vec2, f32)>
for Vec3
and From<(Vec3, f32)
for Vec4
.is_finite
method to all types which returns true
if, and only if, all contained elements are finite.exp
and powf
methods for all vector types.is_nan
method now returns a bool
to match the new is_finite
method and to be consistent with the same methods on the f32
and f64
primitive types.is_nan
which returns a vector mask to is_nan_mask
.cfg
definitions added by build.rs
for defining structs as rust-analyzer
is not aware of them..x()
, .x_mut()
, .set_x()
, etc. on vector and quaternion types..x_axis()
, .x_axis_mut()
, .set_x_axis()
, etc. on matrix types.Vec2::perp
method which returns a Vec2
perpendicular to self
.Vec2
and Vec3
types were changed to use public named fields for .x
, .y
, and .z
instead of accessors.Quat
, Vec3A
and Vec4
implement Deref
and DerefMut
for the new XYZ
and XYZW
structs to emulate public named field access.Mat3
and Mat4
had their axis members made public instead of needing accessors.Mat2
implements Deref
and DerefMut
for the new XYAxes
struct to emulate public named field access.length_reciprocal
and sign
methods.glam
as a no_std
dependency should now work as expected.Vec4::truncate
from Vec3A
to Vec3
.From
implementations to truncate to narrower vector types, e.g. Vec4
to Vec3A
, Vec3
and Vec2
and from Vec3A
and Vec3
to Vec2
.Vec4
, Vec3A
, Vec3
and Vec2
. These can be used to reorder elements in the same type and also to create larger or smaller vectors from the given vectors elements.Quat
operators Add<Quat>
, Sub<Quat>
, Mul<f32>
and Div<f32
. These are used by other crates for interpolation quaternions along splines. Note that these operations will not return unit length quaternions, thus the results must be normalized before performing other Quat
operations.Mat4::transform_point3a
and Mat4::transform_vector3a
.AsRef<[f32; 9]>
and AsMut<[f32; 9]>
trait implementations to Mat3
.bytemuck
support primarily for casting types to &[u8]
.no_std
by disabling the default std
feature and adding the libm
feature.distance
and distance_squared
methods to Vec2
, Vec3
, Vec3A
and Vec4
.glam
uses SSE2 for some types which prevents constructor functions can not be made const fn
. To work around this limitation the following macro functions have been added to support creating const
values of glam
types: const_mat2
, const_mat3
, const_mat4
, const_quat
, const_vec2
, const_vec3
, const_vec3a
and const_vec4
.is_nan
methods to Vec2
, Vec3
, Vec3A
and Vec4
which return a mask.reciprocal
and length_reciprocal
methods to recip
and length_recip
to match the Rust standard library naming. The old methods have been deprecated.sign
methods to signum
match the Rust standard library naming. The new methods now check for NAN
. The old methods have been deprecated.Mat4::determinant
and Mat4::inverse
.Mat4::perspective_glu_rh
.Mat4::transform_point3
to account for homogeneous w coordinate. Previously this would have been incorrect when the resulting homogeneous coordinate was not 1.0, e.g. when transforming by a perspective projection.Mat3::transform_point2
to account for homogeneous z coordinate.Mat4::perspective_rh
.Mat3::mul_vec3a
and Quat::mul_vec3a
.Quat::mul_vec3
to accept and return Vec3
instead of Vec3A
.Mat3 * Vec3A
implementation.Vec3A
benches.Vec3A
type.Vec3
has been split into scalar Vec3
and 16 byte aligned Vec3A
types. Only the Vec3A
type currently uses SIMD optimizations.Vec3Mask
has been split into scalar Vec3Mask
and 16 byte aligned Vec3AMask
types.mut
column accessors to all matrix types, e.g. Mat2::x_axis_mut()
.From
trait implementations for Vec3AMask
and Vec4Mask
to __m128
.Mat3
type is using the scalar Vec3
type for storage.Debug
trait output for Quat
, Vec4
and Vec3A
.packed-vec3
feature flag as it is now redundant.Quat::slerp
- note that this uses a sin
approximation.angle_between
method for Vec2
and Vec3
.Debug
, Display
, PartialEq
, Eq
, PartialOrd
, Ord
, Hash
, and AsRef
traits for Vec2Mask
, Vec3Mask
and Vec4Mask
.Vec2Mask
, Vec3Mask
and Vec4Mask
to an array of [u32]
.build.rs
to simplify conditional feature compilation.cfg-if
dependency.packed-vec3
feature flag to disable using SIMD types for Vec3
and Mat3
types. This avoids wasting some space due to 16 byte alignment at the cost of some performance.x_mut
, y_mut
, z_mut
, w_mut
where appropriate to Vec2
, Vec3
and Vec4
.core::ops::Index
and core::ops::IndexMut
for Vec2
, Vec3
and Vec4
.Vec3
and Vec4
implementations into single files using the cfg-if
crate.Mat4::perspective_lh
, Mat4::perspective_infinite_lh
, Mat4::perspective_infinite_reverse_lh
, Mat4::orthgraphic_lh
and Mat4::orthographic_rh
.round
, ceil
and floor
methods to Vec2
, Vec3
and Vec4
.Mat4::to_scale_rotation_translation
for extracting scale, rotation and translation from a 4x4 homogeneous transformation matrix.cargo-deny
GitHub Action.Quat::new
to Quat::from_xyzw
.Mat4::orthographic_rh_gl
.Mat4::perspective_glu_rh
to Mat4::perspective_rh_gl
.Mat2::determinant
, Mat2::inverse
, Mat2::transpose
, Mat3::transpose
, Quat::conjugate
, Quat::lerp
, Quat::mul_vec3
, Quat::mul_quat
and Quat::from_rotation_ypr
.Mat4::transform_point3
and Mat4::transform_vector3
as they are probably incorrect and need investigating.#[repr(C)]
to Mat2
, Mat3
and Mat4
.Mat2::new
, Mat3::new
and Mat4::new
.glam_assert!
is no longer enabled by default in debug builds, it can be enabled in any configuration using the glam-assert
feature or in debug builds only using the debug-glam-assert
feature.glam_assert!
's checking lerp
is bounded between 0.0 and 1.0 and that matrix scales are non-zero have been removed.Display
trait implementations for Mat2
, Mat3
and Mat4
.glam
's SSE2 sin_cos
implementation - it became less precise for large angle values.is_normalized!
macro from std::f32::EPSILON
to 1e-6
.approx
crate dependency. Each glam
type has an abs_diff_eq
method added which is used by unit tests for approximate floating point comparisons.Angle
type. All angles are now f32
and are expected to be in radians.Vec2b
, Vec3b
and Vec4b
types and the mask
methods on Vec2Mask
, Vec3Mask
and Vec4Mask
.rand
crate dependency has been removed from default features. This was required for benchmarking but a simple random number generator has been added to the benches support
module instead.From
trait implementation converting between 1D and 2D f32
arrays and matrix types have been removed. It was ambiguous how array data would map to matrix columns so these have been replaced with explicit methods from_cols_array
and from_cols_array_2d
.new
methods have been renamed to from_cols
to be consistent with the other methods that create matrices from data.Mat4::perspective_glu
to Mat4::perspective_glu_rh
.Mat4::look_at_lh
and Mat4::look_at_rh
.Mat4::perspective_infinite_rh
and Mat4::perspective_infinite_rh
.Vec2Mask::new
, Vec3Mask::new
and Vec4Mask::new
methods.std::ops
BitAnd
, BitAndAssign
, BitOr
, BitOrAssign
and Not
traits for Vec2Mask
, Vec3Mask
and Vec4Mask
.Vec4
and Vec4Mask
types.serde
implementations for Mat2
, Mat3
and Mat4
.rand
and criterion
versions.Vec4
dot
was missing a shuffle, meaning the dot
, length
, length_squared
, length_reciprocal
and normalize
methods were sometimes incorrect.glam_assert
macro which behaves like Rust's debug_assert
but can be enabled separately to debug_assert
. This is used to perform asserts on correctness.is_normalized
method to Vec2
, Vec3
and Vec4
.std::mem::uninitialized
with std::mem::MaybeUninit
. This change requires stable Rust 1.36.Vec2b
to Vec2Mask
, Vec3b
to Vec3Mask
and Vec4b
to Vec4Mask
. Old names are aliased to the new name and deprecated.VecNMask
mask
method, use new bitmask
method insteadVecNMask
types the same size and alignment as the SIMD versions.Default
support to VecNMask
types, will add more common traits in the future.#[inline]
to mat2
, mat3
and mat4
functions.Mat2
into [f32; 4]
, Mat3
into [f32; 9]
and Mat4
into [f32; 16]
.impl Mul<&Vec2> for Mat2
and impl Mul<&Vec3> for Vec3
as these don't exist for any other types.Mat2
now uses a Vec4
internally which gives it some performance improvements when SSE2 is available.