Struct veloren_voxygen::scene::math::Mat4
source · #[repr(C)]pub struct Mat4<T> {
pub cols: Vec4<Vec4<T>>,
}
Expand description
4x4 matrix.
Fields§
§cols: Vec4<Vec4<T>>
Implementations§
source§impl<T> Mat4<T>
impl<T> Mat4<T>
sourcepub fn identity() -> Mat4<T>
pub fn identity() -> Mat4<T>
The identity matrix, which is also the default value for square matrices.
assert_eq!(Mat4::<f32>::default(), Mat4::<f32>::identity());
sourcepub fn apply<F>(&mut self, f: F)
pub fn apply<F>(&mut self, f: F)
Applies the function f to each element of this matrix, in-place.
For an example, see the map()
method.
sourcepub fn apply2<F, S>(&mut self, other: Mat4<S>, f: F)
pub fn apply2<F, S>(&mut self, other: Mat4<S>, f: F)
Applies the function f to each element of this matrix, in-place.
For an example, see the map2()
method.
sourcepub fn numcast<D>(self) -> Option<Mat4<D>>
pub fn numcast<D>(self) -> Option<Mat4<D>>
Returns a memberwise-converted copy of this matrix, using NumCast
.
let m = Mat4::<f32>::identity();
let m: Mat4<i32> = m.numcast().unwrap();
assert_eq!(m, Mat4::identity());
sourcepub fn broadcast_diagonal(val: T) -> Mat4<T>
pub fn broadcast_diagonal(val: T) -> Mat4<T>
Initializes a new matrix with elements of the diagonal set to val
and the other to zero.
In a way, this is the same as single-argument matrix constructors in GLSL and GLM.
assert_eq!(Mat4::broadcast_diagonal(0), Mat4::zero());
assert_eq!(Mat4::broadcast_diagonal(1), Mat4::identity());
assert_eq!(Mat4::broadcast_diagonal(2), Mat4::new(
2,0,0,0,
0,2,0,0,
0,0,2,0,
0,0,0,2,
));
sourcepub fn with_diagonal(d: Vec4<T>) -> Mat4<T>
pub fn with_diagonal(d: Vec4<T>) -> Mat4<T>
Initializes a matrix by its diagonal, setting other elements to zero.
sourcepub fn diagonal(self) -> Vec4<T>
pub fn diagonal(self) -> Vec4<T>
Gets the matrix’s diagonal into a vector.
assert_eq!(Mat4::<u32>::zero().diagonal(), Vec4::zero());
assert_eq!(Mat4::<u32>::identity().diagonal(), Vec4::one());
let mut m = Mat4::zero();
m[(0, 0)] = 1;
m[(1, 1)] = 2;
m[(2, 2)] = 3;
m[(3, 3)] = 4;
assert_eq!(m.diagonal(), Vec4::new(1, 2, 3, 4));
assert_eq!(m.diagonal(), Vec4::iota() + 1);
sourcepub fn trace(self) -> Twhere
T: Add<Output = T>,
pub fn trace(self) -> Twhere
T: Add<Output = T>,
The sum of the diagonal’s elements.
assert_eq!(Mat4::<u32>::zero().trace(), 0);
assert_eq!(Mat4::<u32>::identity().trace(), 4);
sourcepub fn mul_memberwise(self, m: Mat4<T>) -> Mat4<T>where
T: Mul<Output = T>,
pub fn mul_memberwise(self, m: Mat4<T>) -> Mat4<T>where
T: Mul<Output = T>,
Multiply elements of this matrix with another’s.
let m = Mat4::new(
0, 1, 2, 3,
1, 2, 3, 4,
2, 3, 4, 5,
3, 4, 5, 6,
);
let r = Mat4::new(
0, 1, 4, 9,
1, 4, 9, 16,
4, 9, 16, 25,
9, 16, 25, 36,
);
assert_eq!(m.mul_memberwise(m), r);
sourcepub const ROW_COUNT: usize = 4usize
pub const ROW_COUNT: usize = 4usize
Convenience constant representing the number of rows for matrices of this type.
source§impl<T> Mat4<T>
impl<T> Mat4<T>
sourcepub fn map_cols<D, F>(self, f: F) -> Mat4<D>
pub fn map_cols<D, F>(self, f: F) -> Mat4<D>
Returns a column-wise-converted copy of this matrix, using the given conversion closure.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<f32>::new(
0.25, 1.25, 5.56, 8.66,
8.53, 2.92, 3.86, 9.36,
1.02, 0.28, 5.52, 6.06,
6.20, 7.01, 4.90, 5.26
);
let m = m.map_cols(|col| col.map(|x| x.round() as i32));
assert_eq!(m, Mat4::new(
0, 1, 6, 9,
9, 3, 4, 9,
1, 0, 6, 6,
6, 7, 5, 5
));
sourcepub fn into_col_array(self) -> [T; 16]
pub fn into_col_array(self) -> [T; 16]
Converts this matrix into a fixed-size array of elements.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
0, 4, 8, 12,
1, 5, 9, 13,
2, 6, 10, 14,
3, 7, 11, 15
];
assert_eq!(m.into_col_array(), array);
sourcepub fn into_col_arrays(self) -> [[T; 4]; 4]
pub fn into_col_arrays(self) -> [[T; 4]; 4]
Converts this matrix into a fixed-size array of fixed-size arrays of elements.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
[ 0, 4, 8, 12, ],
[ 1, 5, 9, 13, ],
[ 2, 6, 10, 14, ],
[ 3, 7, 11, 15, ],
];
assert_eq!(m.into_col_arrays(), array);
sourcepub fn from_col_array(array: [T; 16]) -> Mat4<T>
pub fn from_col_array(array: [T; 16]) -> Mat4<T>
Converts a fixed-size array of elements into a matrix.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
0, 4, 8, 12,
1, 5, 9, 13,
2, 6, 10, 14,
3, 7, 11, 15
];
assert_eq!(m, Mat4::from_col_array(array));
sourcepub fn from_col_arrays(array: [[T; 4]; 4]) -> Mat4<T>
pub fn from_col_arrays(array: [[T; 4]; 4]) -> Mat4<T>
Converts a fixed-size array of fixed-size arrays of elements into a matrix.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
[ 0, 4, 8, 12, ],
[ 1, 5, 9, 13, ],
[ 2, 6, 10, 14, ],
[ 3, 7, 11, 15, ],
];
assert_eq!(m, Mat4::from_col_arrays(array));
sourcepub fn into_row_array(self) -> [T; 16]
pub fn into_row_array(self) -> [T; 16]
Converts this matrix into a fixed-size array of elements.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
];
assert_eq!(m.into_row_array(), array);
sourcepub fn into_row_arrays(self) -> [[T; 4]; 4]
pub fn into_row_arrays(self) -> [[T; 4]; 4]
Converts this matrix into a fixed-size array of fixed-size arrays of elements.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
[ 0, 1, 2, 3, ],
[ 4, 5, 6, 7, ],
[ 8, 9, 10, 11, ],
[ 12, 13, 14, 15, ],
];
assert_eq!(m.into_row_arrays(), array);
sourcepub fn from_row_array(array: [T; 16]) -> Mat4<T>
pub fn from_row_array(array: [T; 16]) -> Mat4<T>
Converts a fixed-size array of elements into a matrix.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
];
assert_eq!(m, Mat4::from_row_array(array));
sourcepub fn from_row_arrays(array: [[T; 4]; 4]) -> Mat4<T>
pub fn from_row_arrays(array: [[T; 4]; 4]) -> Mat4<T>
Converts a fixed-size array of fixed-size array of elements into a matrix.
use vek::mat::repr_c::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
);
let array = [
[ 0, 1, 2, 3, ],
[ 4, 5, 6, 7, ],
[ 8, 9, 10, 11, ],
[ 12, 13, 14, 15, ],
];
assert_eq!(m, Mat4::from_row_arrays(array));
sourcepub fn as_col_ptr(&self) -> *const T
pub fn as_col_ptr(&self) -> *const T
Gets a const pointer to this matrix’s elements.
§Panics
Panics if the matrix’s elements are not tightly packed in memory,
which may be the case for matrices in the repr_simd
module.
You may check this with the is_packed()
method.
sourcepub fn as_mut_col_ptr(&mut self) -> *mut T
pub fn as_mut_col_ptr(&mut self) -> *mut T
Gets a mut pointer to this matrix’s elements.
§Panics
Panics if the matrix’s elements are not tightly packed in memory,
which may be the case for matrices in the repr_simd
module.
You may check this with the is_packed()
method.
sourcepub fn as_col_slice(&self) -> &[T]
pub fn as_col_slice(&self) -> &[T]
View this matrix as an immutable slice.
§Panics
Panics if the matrix’s elements are not tightly packed in memory,
which may be the case for matrices in the repr_simd
module.
You may check this with the is_packed()
method.
sourcepub fn as_mut_col_slice(&mut self) -> &mut [T]
pub fn as_mut_col_slice(&mut self) -> &mut [T]
View this matrix as a mutable slice.
§Panics
Panics if the matrix’s elements are not tightly packed in memory,
which may be the case for matrices in the repr_simd
module.
You may check this with the is_packed()
method.
source§impl<T> Mat4<T>
impl<T> Mat4<T>
sourcepub fn gl_should_transpose(&self) -> bool
pub fn gl_should_transpose(&self) -> bool
Gets the transpose
parameter to pass to OpenGL glUniformMatrix*()
functions.
The return value is a plain bool
which you may directly cast
to a GLboolean
.
This takes &self
to prevent surprises when changing the type
of matrix you plan to send.
sourcepub const GL_SHOULD_TRANSPOSE: bool = false
pub const GL_SHOULD_TRANSPOSE: bool = false
The transpose
parameter to pass to OpenGL glUniformMatrix*()
functions.
source§impl<T> Mat4<T>
impl<T> Mat4<T>
sourcepub fn new(
m00: T,
m01: T,
m02: T,
m03: T,
m10: T,
m11: T,
m12: T,
m13: T,
m20: T,
m21: T,
m22: T,
m23: T,
m30: T,
m31: T,
m32: T,
m33: T,
) -> Mat4<T>
pub fn new( m00: T, m01: T, m02: T, m03: T, m10: T, m11: T, m12: T, m13: T, m20: T, m21: T, m22: T, m23: T, m30: T, m31: T, m32: T, m33: T, ) -> Mat4<T>
Creates a new 4x4 matrix from elements in a layout-agnostic way.
The parameters are named mij
where i
is the row index and
j
the column index. Their order is always the same regardless
of the matrix’s layout.
source§impl<T> Mat4<T>
impl<T> Mat4<T>
sourcepub fn map<D, F>(self, f: F) -> Mat4<D>where
F: FnMut(T) -> D,
pub fn map<D, F>(self, f: F) -> Mat4<D>where
F: FnMut(T) -> D,
Returns an element-wise-converted copy of this matrix, using the given conversion closure.
use vek::mat::repr_c::row_major::Mat4;
let m = Mat4::<f32>::new(
0.25, 1.25, 5.56, 8.66,
8.53, 2.92, 3.86, 9.36,
1.02, 0.28, 5.52, 6.06,
6.20, 7.01, 4.90, 5.26
);
let m = m.map(|x| x.round() as i32);
assert_eq!(m, Mat4::new(
0, 1, 6, 9,
9, 3, 4, 9,
1, 0, 6, 6,
6, 7, 5, 5
));
sourcepub fn as_<D>(self) -> Mat4<D>where
T: AsPrimitive<D>,
D: 'static + Copy,
pub fn as_<D>(self) -> Mat4<D>where
T: AsPrimitive<D>,
D: 'static + Copy,
Returns a memberwise-converted copy of this matrix, using AsPrimitive
.
§Examples
let v = Vec4::new(0_f32, 1., 2., 3.);
let i: Vec4<i32> = v.as_();
assert_eq!(i, Vec4::new(0, 1, 2, 3));
§Safety
In Rust versions before 1.45.0, some uses of the as
operator were not entirely safe.
In particular, it was undefined behavior if
a truncated floating point value could not fit in the target integer
type (#10184);
let x: u8 = (1.04E+17).as_(); // UB
sourcepub fn map2<D, F, S>(self, other: Mat4<S>, f: F) -> Mat4<D>where
F: FnMut(T, S) -> D,
pub fn map2<D, F, S>(self, other: Mat4<S>, f: F) -> Mat4<D>where
F: FnMut(T, S) -> D,
Applies the function f to each element of two matrices, pairwise, and returns the result.
use vek::mat::repr_c::row_major::Mat4;
let a = Mat4::<f32>::new(
0.25, 1.25, 2.52, 2.99,
0.25, 1.25, 2.52, 2.99,
0.25, 1.25, 2.52, 2.99,
0.25, 1.25, 2.52, 2.99
);
let b = Mat4::<i32>::new(
0, 1, 0, 0,
1, 0, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
let m = a.map2(b, |a, b| a.round() as i32 + b);
assert_eq!(m, Mat4::new(
0, 2, 3, 3,
1, 1, 3, 3,
0, 1, 4, 3,
0, 1, 3, 4
));
sourcepub fn transposed(self) -> Mat4<T>
pub fn transposed(self) -> Mat4<T>
The matrix’s transpose.
For orthogonal matrices, the transpose is the same as the inverse. All pure rotation matrices are orthogonal, and therefore can be inverted faster by simply computing their transpose.
use std::f32::consts::PI;
let m = Mat4::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 0, 1,
2, 3, 4, 5
);
let t = Mat4::new(
0, 4, 8, 2,
1, 5, 9, 3,
2, 6, 0, 4,
3, 7, 1, 5
);
assert_eq!(m.transposed(), t);
assert_eq!(m, m.transposed().transposed());
// By the way, demonstrate ways to invert a rotation matrix,
// from fastest (specific) to slowest (general-purpose).
let m = Mat4::rotation_x(PI/7.);
let id = Mat4::identity();
assert_relative_eq!(id, m * m.transposed());
assert_relative_eq!(id, m.transposed() * m);
assert_relative_eq!(id, m * m.inverted_affine_transform_no_scale());
assert_relative_eq!(id, m.inverted_affine_transform_no_scale() * m);
assert_relative_eq!(id, m * m.inverted_affine_transform());
assert_relative_eq!(id, m.inverted_affine_transform() * m);
assert_relative_eq!(id, m * m.inverted());
assert_relative_eq!(id, m.inverted() * m);
sourcepub fn transpose(&mut self)
pub fn transpose(&mut self)
Transpose this matrix.
let mut m = Mat4::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 0, 1,
2, 3, 4, 5
);
let t = Mat4::new(
0, 4, 8, 2,
1, 5, 9, 3,
2, 6, 0, 4,
3, 7, 1, 5
);
m.transpose();
assert_eq!(m, t);
sourcepub fn determinant(self) -> T
pub fn determinant(self) -> T
Get this matrix’s determinant.
A matrix is invertible if its determinant is non-zero.
sourcepub fn invert(&mut self)where
T: Real,
pub fn invert(&mut self)where
T: Real,
Inverts this matrix, blindly assuming that it is invertible.
See inverted()
for more info.
sourcepub fn inverted(self) -> Mat4<T>where
T: Real,
pub fn inverted(self) -> Mat4<T>where
T: Real,
Returns this matrix’s inverse, blindly assuming that it is invertible.
All affine matrices have inverses; Your matrices may be affine as long as they consist of any combination of pure rotations, translations, scales and shears.
use vek::vec::repr_c::Vec3;
use vek::mat::repr_c::row_major::Mat4 as Rows4;
use vek::mat::repr_c::column_major::Mat4 as Cols4;
use std::f32::consts::PI;
let a = Rows4::scaling_3d(1.77_f32)
.rotated_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted();
assert_relative_eq!(a*b, Rows4::identity(), epsilon = 0.000001);
assert_relative_eq!(b*a, Rows4::identity(), epsilon = 0.000001);
let a = Cols4::scaling_3d(1.77_f32)
.rotated_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted();
assert_relative_eq!(a*b, Cols4::identity(), epsilon = 0.000001);
assert_relative_eq!(b*a, Cols4::identity(), epsilon = 0.000001);
// Beware, projection matrices are not invertible!
// Notice that we assert _inequality_ below.
let a = Cols4::perspective_rh_zo(60_f32.to_radians(), 16./9., 0.001, 1000.) * a;
let b = a.inverted();
assert_relative_ne!(a*b, Cols4::identity(), epsilon = 0.000001);
assert_relative_ne!(b*a, Cols4::identity(), epsilon = 0.000001);
sourcepub fn invert_affine_transform_no_scale(&mut self)where
T: Real,
pub fn invert_affine_transform_no_scale(&mut self)where
T: Real,
Returns this matrix’s inverse, blindly assuming that it is an invertible transform matrix which scale is 1.
See inverted_affine_transform_no_scale()
for more info.
sourcepub fn inverted_affine_transform_no_scale(self) -> Mat4<T>where
T: Real,
pub fn inverted_affine_transform_no_scale(self) -> Mat4<T>where
T: Real,
Returns this matrix’s inverse, blindly assuming that it is an invertible transform matrix which scale is 1.
A transform matrix is invertible this way as long as it consists of translations, rotations, and shears. It’s not guaranteed to work if the scale is not 1.
use vek::vec::repr_c::Vec3;
use vek::mat::repr_c::row_major::Mat4 as Rows4;
use vek::mat::repr_c::column_major::Mat4 as Cols4;
use std::f32::consts::PI;
let a = Rows4::rotation_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted_affine_transform_no_scale();
assert_relative_eq!(a*b, Rows4::identity(), epsilon = 0.000001);
assert_relative_eq!(b*a, Rows4::identity(), epsilon = 0.000001);
let a = Cols4::rotation_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted_affine_transform_no_scale();
assert_relative_eq!(a*b, Cols4::identity(), epsilon = 0.000001);
assert_relative_eq!(b*a, Cols4::identity(), epsilon = 0.000001);
// Look! It stops working as soon as we add a scale.
// Notice that we assert _inequality_ below.
let a = Rows4::scaling_3d(5_f32)
.rotated_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted_affine_transform_no_scale();
assert_relative_ne!(a*b, Rows4::identity(), epsilon = 0.000001);
assert_relative_ne!(b*a, Rows4::identity(), epsilon = 0.000001);
sourcepub fn invert_affine_transform(&mut self)where
T: Real,
pub fn invert_affine_transform(&mut self)where
T: Real,
Inverts this matrix, blindly assuming that it is an invertible transform matrix.
See inverted_affine_transform()
for more info.
sourcepub fn inverted_affine_transform(self) -> Mat4<T>where
T: Real,
pub fn inverted_affine_transform(self) -> Mat4<T>where
T: Real,
Returns this matrix’s inverse, blindly assuming that it is an invertible transform matrix.
A transform matrix is invertible this way as long as it consists of translations, rotations, scales and shears.
use vek::vec::repr_c::Vec3;
use vek::mat::repr_c::row_major::Mat4 as Rows4;
use vek::mat::repr_c::column_major::Mat4 as Cols4;
use std::f32::consts::PI;
let a = Rows4::scaling_3d(1.77_f32)
.rotated_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted_affine_transform();
assert_relative_eq!(a*b, Rows4::identity(), epsilon = 0.000001);
assert_relative_eq!(b*a, Rows4::identity(), epsilon = 0.000001);
let a = Cols4::scaling_3d(1.77_f32)
.rotated_3d(PI*4./5., Vec3::new(5., 8., 10.))
.translated_3d(Vec3::new(1., 2., 3.));
let b = a.inverted_affine_transform();
assert_relative_eq!(a*b, Cols4::identity(), epsilon = 0.000001);
assert_relative_eq!(b*a, Cols4::identity(), epsilon = 0.000001);
sourcepub fn mul_direction<V>(self, rhs: V) -> V
pub fn mul_direction<V>(self, rhs: V) -> V
Shortcut for self * Vec4::from_direction(rhs)
.
sourcepub fn translate_2d<V>(&mut self, v: V)
pub fn translate_2d<V>(&mut self, v: V)
Translates this matrix in 2D.
sourcepub fn translated_2d<V>(self, v: V) -> Mat4<T>
pub fn translated_2d<V>(self, v: V) -> Mat4<T>
Returns this matrix translated in 2D.
sourcepub fn translation_2d<V>(v: V) -> Mat4<T>
pub fn translation_2d<V>(v: V) -> Mat4<T>
Creates a 2D translation matrix.
sourcepub fn translate_3d<V>(&mut self, v: V)
pub fn translate_3d<V>(&mut self, v: V)
Translates this matrix in 3D.
sourcepub fn translated_3d<V>(self, v: V) -> Mat4<T>
pub fn translated_3d<V>(self, v: V) -> Mat4<T>
Returns this matrix translated in 3D.
sourcepub fn translation_3d<V>(v: V) -> Mat4<T>
pub fn translation_3d<V>(v: V) -> Mat4<T>
Creates a 3D translation matrix.
sourcepub fn scaling_3d<V>(v: V) -> Mat4<T>
pub fn scaling_3d<V>(v: V) -> Mat4<T>
Creates a 3D scaling matrix.
sourcepub fn rotated_x(self, angle_radians: T) -> Mat4<T>
pub fn rotated_x(self, angle_radians: T) -> Mat4<T>
Returns this matrix rotated around the X axis.
sourcepub fn rotation_x(angle_radians: T) -> Mat4<T>where
T: Real,
pub fn rotation_x(angle_radians: T) -> Mat4<T>where
T: Real,
Creates a matrix that rotates around the X axis.
sourcepub fn rotated_y(self, angle_radians: T) -> Mat4<T>
pub fn rotated_y(self, angle_radians: T) -> Mat4<T>
Returns this matrix rotated around the Y axis.
sourcepub fn rotation_y(angle_radians: T) -> Mat4<T>where
T: Real,
pub fn rotation_y(angle_radians: T) -> Mat4<T>where
T: Real,
Creates a matrix that rotates around the Y axis.
sourcepub fn rotated_z(self, angle_radians: T) -> Mat4<T>
pub fn rotated_z(self, angle_radians: T) -> Mat4<T>
Returns this matrix rotated around the Z axis.
sourcepub fn rotation_z(angle_radians: T) -> Mat4<T>where
T: Real,
pub fn rotation_z(angle_radians: T) -> Mat4<T>where
T: Real,
Creates a matrix that rotates around the Z axis.
sourcepub fn rotate_3d<V>(&mut self, angle_radians: T, axis: V)
pub fn rotate_3d<V>(&mut self, angle_radians: T, axis: V)
Rotates this matrix around a 3D axis. The axis is not required to be normalized.
sourcepub fn rotated_3d<V>(self, angle_radians: T, axis: V) -> Mat4<T>
pub fn rotated_3d<V>(self, angle_radians: T, axis: V) -> Mat4<T>
Returns this matrix rotated around a 3D axis. The axis is not required to be normalized.
sourcepub fn rotation_3d<V>(angle_radians: T, axis: V) -> Mat4<T>
pub fn rotation_3d<V>(angle_radians: T, axis: V) -> Mat4<T>
Creates a matrix that rotates around a 3D axis. The axis is not required to be normalized.
use std::f32::consts::PI;
let v = Vec4::unit_x();
let m = Mat4::rotation_z(PI);
assert_relative_eq!(m * v, -v);
let m = Mat4::rotation_z(PI * 0.5);
assert_relative_eq!(m * v, Vec4::unit_y());
let m = Mat4::rotation_z(PI * 1.5);
assert_relative_eq!(m * v, -Vec4::unit_y());
let angles = 32;
for i in 0..angles {
let theta = PI * 2. * (i as f32) / (angles as f32);
// See what rotating unit vectors do for most angles between 0 and 2*PI.
// It's helpful to picture this as a right-handed coordinate system.
let v = Vec4::unit_y();
let m = Mat4::rotation_x(theta);
assert_relative_eq!(m * v, Vec4::new(0., theta.cos(), theta.sin(), 0.));
let v = Vec4::unit_z();
let m = Mat4::rotation_y(theta);
assert_relative_eq!(m * v, Vec4::new(theta.sin(), 0., theta.cos(), 0.));
let v = Vec4::unit_x();
let m = Mat4::rotation_z(theta);
assert_relative_eq!(m * v, Vec4::new(theta.cos(), theta.sin(), 0., 0.));
assert_relative_eq!(Mat4::rotation_x(theta), Mat4::rotation_3d(theta, Vec4::unit_x()));
assert_relative_eq!(Mat4::rotation_y(theta), Mat4::rotation_3d(theta, Vec4::unit_y()));
assert_relative_eq!(Mat4::rotation_z(theta), Mat4::rotation_3d(theta, Vec4::unit_z()));
}
sourcepub fn rotation_from_to_3d<V>(from: V, to: V) -> Mat4<T>
pub fn rotation_from_to_3d<V>(from: V, to: V) -> Mat4<T>
Creates a matrix that would rotate a from
direction to to
.
let (from, to) = (Vec4::<f32>::unit_x(), Vec4::<f32>::unit_z());
let m = Mat4::<f32>::rotation_from_to_3d(from, to);
assert_relative_eq!(m * from, to);
let (from, to) = (Vec4::<f32>::unit_x(), -Vec4::<f32>::unit_x());
let m = Mat4::<f32>::rotation_from_to_3d(from, to);
assert_relative_eq!(m * from, to);
sourcepub fn basis_to_local<V>(origin: V, i: V, j: V, k: V) -> Mat4<T>
pub fn basis_to_local<V>(origin: V, i: V, j: V, k: V) -> Mat4<T>
Builds a change of basis matrix that transforms points and directions from any space to the canonical one.
origin
is the origin of the child space.
i
, j
and k
are all required to be normalized;
They are the unit basis vector along the target space x-axis, y-axis and z-axis
respectively, expressed in canonical-space coordinates.
let origin = Vec3::new(1_f32, 2., 3.);
let i = Vec3::unit_z();
let j = Vec3::unit_y();
let k = Vec3::unit_x();
let m = Mat4::basis_to_local(origin, i, j, k);
assert_relative_eq!(m.mul_point(origin), Vec3::zero());
assert_relative_eq!(m.mul_point(origin+i), Vec3::unit_x());
assert_relative_eq!(m.mul_point(origin+j), Vec3::unit_y());
assert_relative_eq!(m.mul_point(origin+k), Vec3::unit_z());
// `local_to_basis` and `basis_to_local` undo each other
let a = Mat4::<f32>::basis_to_local(origin, i, j, k);
let b = Mat4::<f32>::local_to_basis(origin, i, j, k);
assert_relative_eq!(a*b, Mat4::identity());
assert_relative_eq!(b*a, Mat4::identity());
Slightly more contrived example:
let origin = Vec3::new(1_f32, 2., 3.);
let r = Mat4::rotation_3d(3., Vec3::new(2_f32, 1., 3.));
let i = r.mul_direction(Vec3::unit_x());
let j = r.mul_direction(Vec3::unit_y());
let k = r.mul_direction(Vec3::unit_z());
let m = Mat4::basis_to_local(origin, i, j, k);
assert_relative_eq!(m.mul_point(origin), Vec3::zero(), epsilon = 0.000001);
assert_relative_eq!(m.mul_point(origin+i), Vec3::unit_x(), epsilon = 0.000001);
assert_relative_eq!(m.mul_point(origin+j), Vec3::unit_y(), epsilon = 0.000001);
assert_relative_eq!(m.mul_point(origin+k), Vec3::unit_z(), epsilon = 0.000001);
sourcepub fn local_to_basis<V>(origin: V, i: V, j: V, k: V) -> Mat4<T>
pub fn local_to_basis<V>(origin: V, i: V, j: V, k: V) -> Mat4<T>
Builds a change of basis matrix that transforms points and directions from canonical space to another space.
origin
is the origin of the child space.
i
, j
and k
are all required to be normalized;
They are the unit basis vector along the target space x-axis, y-axis and z-axis
respectively, expressed in canonical-space coordinates.
let origin = Vec3::new(1_f32, 2., 3.);
let i = Vec3::unit_z();
let j = Vec3::unit_y();
let k = Vec3::unit_x();
let m = Mat4::local_to_basis(origin, i, j, k);
assert_relative_eq!(origin, m.mul_point(Vec3::zero()));
assert_relative_eq!(origin+i, m.mul_point(Vec3::unit_x()));
assert_relative_eq!(origin+j, m.mul_point(Vec3::unit_y()));
assert_relative_eq!(origin+k, m.mul_point(Vec3::unit_z()));
// `local_to_basis` and `basis_to_local` undo each other
let a = Mat4::<f32>::local_to_basis(origin, i, j, k);
let b = Mat4::<f32>::basis_to_local(origin, i, j, k);
assert_relative_eq!(a*b, Mat4::identity());
assert_relative_eq!(b*a, Mat4::identity());
Slightly more contrived example:
// Sanity test
let origin = Vec3::new(1_f32, 2., 3.);
let r = Mat4::rotation_3d(3., Vec3::new(2_f32, 1., 3.));
let i = r.mul_direction(Vec3::unit_x());
let j = r.mul_direction(Vec3::unit_y());
let k = r.mul_direction(Vec3::unit_z());
let m = Mat4::local_to_basis(origin, i, j, k);
assert_relative_eq!(origin, m.mul_point(Vec3::zero()));
assert_relative_eq!(origin+i, m.mul_point(Vec3::unit_x()));
assert_relative_eq!(origin+j, m.mul_point(Vec3::unit_y()));
assert_relative_eq!(origin+k, m.mul_point(Vec3::unit_z()));
sourcepub fn look_at<V>(eye: V, target: V, up: V) -> Mat4<T>
👎Deprecated since 0.9.7: Use look_at_lh() or look_at_rh() instead depending on your space’s handedness
pub fn look_at<V>(eye: V, target: V, up: V) -> Mat4<T>
Builds a “look at” view transform from an eye position, a target position, and up vector. Commonly used for cameras - in short, it maps points from world-space to eye-space.
sourcepub fn look_at_lh<V>(eye: V, target: V, up: V) -> Mat4<T>
pub fn look_at_lh<V>(eye: V, target: V, up: V) -> Mat4<T>
Builds a “look at” view transform for left-handed spaces from an eye position, a target position, and up vector. Commonly used for cameras - in short, it maps points from world-space to eye-space.
let eye = Vec4::new(1_f32, 0., 1., 1.);
let target = Vec4::new(2_f32, 0., 2., 1.);
let view = Mat4::<f32>::look_at_lh(eye, target, Vec4::unit_y());
assert_relative_eq!(view * eye, Vec4::unit_w());
assert_relative_eq!(view * target, Vec4::new(0_f32, 0., 2_f32.sqrt(), 1.));
sourcepub fn look_at_rh<V>(eye: V, target: V, up: V) -> Mat4<T>
pub fn look_at_rh<V>(eye: V, target: V, up: V) -> Mat4<T>
Builds a “look at” view transform for right-handed spaces from an eye position, a target position, and up vector. Commonly used for cameras - in short, it maps points from world-space to eye-space.
let eye = Vec4::new(1_f32, 0., 1., 1.);
let target = Vec4::new(2_f32, 0., 2., 1.);
let view = Mat4::<f32>::look_at_rh(eye, target, Vec4::unit_y());
assert_relative_eq!(view * eye, Vec4::unit_w());
assert_relative_eq!(view * target, Vec4::new(0_f32, 0., -2_f32.sqrt(), 1.));
sourcepub fn model_look_at<V>(eye: V, target: V, up: V) -> Mat4<T>
👎Deprecated since 0.9.7: Use model_look_at_lh() or model_look_at_rh() instead depending on your space’s handedness
pub fn model_look_at<V>(eye: V, target: V, up: V) -> Mat4<T>
Builds a “look at” model transform from an eye position, a target position, and up vector. Preferred for transforming objects.
sourcepub fn model_look_at_lh<V>(eye: V, target: V, up: V) -> Mat4<T>
pub fn model_look_at_lh<V>(eye: V, target: V, up: V) -> Mat4<T>
Builds a “look at” model transform for left-handed spaces from an eye position, a target position, and up vector. Preferred for transforming objects.
let eye = Vec4::new(1_f32, 0., 1., 1.);
let target = Vec4::new(2_f32, 0., 2., 1.);
let model = Mat4::<f32>::model_look_at_lh(eye, target, Vec4::unit_y());
assert_relative_eq!(model * Vec4::unit_w(), eye);
let d = 2_f32.sqrt();
assert_relative_eq!(model * Vec4::new(0_f32, 0., d, 1.), target);
// A "model" look-at essentially undoes a "view" look-at
let view = Mat4::look_at_lh(eye, target, Vec4::unit_y());
assert_relative_eq!(view * model, Mat4::identity());
assert_relative_eq!(model * view, Mat4::identity());
sourcepub fn model_look_at_rh<V>(eye: V, target: V, up: V) -> Mat4<T>
pub fn model_look_at_rh<V>(eye: V, target: V, up: V) -> Mat4<T>
Builds a “look at” model transform for right-handed spaces from an eye position, a target position, and up vector. Preferred for transforming objects.
let eye = Vec4::new(1_f32, 0., -1., 1.);
let forward = Vec4::new(0_f32, 0., -1., 0.);
let model = Mat4::<f32>::model_look_at_rh(eye, eye + forward, Vec4::unit_y());
assert_relative_eq!(model * Vec4::unit_w(), eye);
assert_relative_eq!(model * forward, forward);
// A "model" look-at essentially undoes a "view" look-at
let view = Mat4::look_at_rh(eye, eye + forward, Vec4::unit_y());
assert_relative_eq!(view * model, Mat4::identity());
assert_relative_eq!(model * view, Mat4::identity());
sourcepub fn orthographic_without_depth_planes(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn orthographic_without_depth_planes(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Returns an orthographic projection matrix that doesn’t use near and far planes.
sourcepub fn orthographic_lh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn orthographic_lh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Returns an orthographic projection matrix for left-handed spaces,
for a depth clip space ranging from 0 to 1 (GL_DEPTH_ZERO_TO_ONE
,
hence the _zo
suffix).
let m = Mat4::orthographic_lh_zo(FrustumPlanes {
left: -1_f32, right: 1., bottom: -1., top: 1.,
near: 0., far: 1.
});
let v = Vec4::new(0_f32, 0., 1., 1.); // "forward"
assert_relative_eq!(m * v, Vec4::new(0., 0., 1., 1.)); // "far"
sourcepub fn orthographic_lh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn orthographic_lh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Returns an orthographic projection matrix for left-handed spaces,
for a depth clip space ranging from -1 to 1 (GL_DEPTH_NEGATIVE_ONE_TO_ONE
,
hence the _no
suffix).
let m = Mat4::orthographic_lh_no(FrustumPlanes {
left: -1_f32, right: 1., bottom: -1., top: 1.,
near: 0., far: 1.
});
let v = Vec4::new(0_f32, 0., 1., 1.); // "forward"
assert_relative_eq!(m * v, Vec4::new(0., 0., 1., 1.)); // "far"
sourcepub fn orthographic_rh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn orthographic_rh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Returns an orthographic projection matrix for right-handed spaces,
for a depth clip space ranging from 0 to 1 (GL_DEPTH_ZERO_TO_ONE
,
hence the _zo
suffix).
let m = Mat4::orthographic_rh_zo(FrustumPlanes {
left: -1_f32, right: 1., bottom: -1., top: 1.,
near: 0., far: 1.
});
let v = Vec4::new(0_f32, 0., -1., 1.); // "forward"
assert_relative_eq!(m * v, Vec4::new(0., 0., 1., 1.)); // "far"
sourcepub fn orthographic_rh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn orthographic_rh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Returns an orthographic projection matrix for right-handed spaces,
for a depth clip space ranging from -1 to 1 (GL_DEPTH_NEGATIVE_ONE_TO_ONE
,
hence the _no
suffix).
let m = Mat4::orthographic_rh_no(FrustumPlanes {
left: -1_f32, right: 1., bottom: -1., top: 1.,
near: 0., far: 1.
});
let v = Vec4::new(0_f32, 0., -1., 1.); // "forward"
assert_relative_eq!(m * v, Vec4::new(0., 0., 1., 1.)); // "far"
sourcepub fn frustum_lh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn frustum_lh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Creates a perspective projection matrix from a frustum (left-handed, zero-to-one depth clip planes).
sourcepub fn frustum_lh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn frustum_lh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Creates a perspective projection matrix from a frustum (left-handed, negative-one-to-one depth clip planes).
sourcepub fn frustum_rh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn frustum_rh_zo(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Creates a perspective projection matrix from a frustum (right-handed, zero-to-one depth clip planes).
sourcepub fn frustum_rh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
pub fn frustum_rh_no(o: FrustumPlanes<T>) -> Mat4<T>where
T: Real,
Creates a perspective projection matrix from a frustum (right-handed, negative-one-to-one depth clip planes).
sourcepub fn perspective_rh_zo(
fov_y_radians: T,
aspect_ratio: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_rh_zo( fov_y_radians: T, aspect_ratio: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for right-handed spaces, with zero-to-one depth clip planes.
sourcepub fn perspective_lh_zo(
fov_y_radians: T,
aspect_ratio: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_lh_zo( fov_y_radians: T, aspect_ratio: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for left-handed spaces, with zero-to-one depth clip planes.
sourcepub fn perspective_rh_no(
fov_y_radians: T,
aspect_ratio: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_rh_no( fov_y_radians: T, aspect_ratio: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for right-handed spaces, with negative-one-to-one depth clip planes.
sourcepub fn perspective_lh_no(
fov_y_radians: T,
aspect_ratio: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_lh_no( fov_y_radians: T, aspect_ratio: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for left-handed spaces, with negative-one-to-one depth clip planes.
sourcepub fn perspective_fov_rh_zo(
fov_y_radians: T,
width: T,
height: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_fov_rh_zo( fov_y_radians: T, width: T, height: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for right-handed spaces, with zero-to-one depth clip planes.
§Panics
width
, height
and fov_y_radians
must all be strictly greater than zero.
sourcepub fn perspective_fov_lh_zo(
fov_y_radians: T,
width: T,
height: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_fov_lh_zo( fov_y_radians: T, width: T, height: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for left-handed spaces, with zero-to-one depth clip planes.
§Panics
width
, height
and fov_y_radians
must all be strictly greater than zero.
sourcepub fn perspective_fov_rh_no(
fov_y_radians: T,
width: T,
height: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_fov_rh_no( fov_y_radians: T, width: T, height: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for right-handed spaces, with negative-one-to-one depth clip planes.
§Panics
width
, height
and fov_y_radians
must all be strictly greater than zero.
sourcepub fn perspective_fov_lh_no(
fov_y_radians: T,
width: T,
height: T,
near: T,
far: T,
) -> Mat4<T>
pub fn perspective_fov_lh_no( fov_y_radians: T, width: T, height: T, near: T, far: T, ) -> Mat4<T>
Creates a perspective projection matrix for left-handed spaces, with negative-one-to-one depth clip planes.
§Panics
width
, height
and fov_y_radians
must all be strictly greater than zero.
sourcepub fn tweaked_infinite_perspective_rh(
fov_y_radians: T,
aspect_ratio: T,
near: T,
epsilon: T,
) -> Mat4<T>
pub fn tweaked_infinite_perspective_rh( fov_y_radians: T, aspect_ratio: T, near: T, epsilon: T, ) -> Mat4<T>
Creates an infinite perspective projection matrix for right-handed spaces.
sourcepub fn tweaked_infinite_perspective_lh(
fov_y_radians: T,
aspect_ratio: T,
near: T,
epsilon: T,
) -> Mat4<T>
pub fn tweaked_infinite_perspective_lh( fov_y_radians: T, aspect_ratio: T, near: T, epsilon: T, ) -> Mat4<T>
Creates an infinite perspective projection matrix for left-handed spaces.
sourcepub fn infinite_perspective_rh(
fov_y_radians: T,
aspect_ratio: T,
near: T,
) -> Mat4<T>
pub fn infinite_perspective_rh( fov_y_radians: T, aspect_ratio: T, near: T, ) -> Mat4<T>
Creates an infinite perspective projection matrix for right-handed spaces.
sourcepub fn infinite_perspective_lh(
fov_y_radians: T,
aspect_ratio: T,
near: T,
) -> Mat4<T>
pub fn infinite_perspective_lh( fov_y_radians: T, aspect_ratio: T, near: T, ) -> Mat4<T>
Creates an infinite perspective projection matrix for left-handed spaces.
sourcepub fn picking_region<V2>(
center: V2,
delta: V2,
viewport: Rect<T, T>,
) -> Mat4<T>
pub fn picking_region<V2>( center: V2, delta: V2, viewport: Rect<T, T>, ) -> Mat4<T>
GLM’s pickMatrix. Creates a projection matrix that can be used to restrict drawing to a small region of the viewport.
§Panics
delta
’s x
and y
are required to be strictly greater than zero.
sourcepub fn world_to_viewport_no<V3>(
obj: V3,
modelview: Mat4<T>,
proj: Mat4<T>,
viewport: Rect<T, T>,
) -> Vec3<T>
pub fn world_to_viewport_no<V3>( obj: V3, modelview: Mat4<T>, proj: Mat4<T>, viewport: Rect<T, T>, ) -> Vec3<T>
Projects a world-space coordinate into screen space,
for a depth clip space ranging from -1 to 1 (GL_DEPTH_NEGATIVE_ONE_TO_ONE
,
hence the _no
suffix).
sourcepub fn world_to_viewport_zo<V3>(
obj: V3,
modelview: Mat4<T>,
proj: Mat4<T>,
viewport: Rect<T, T>,
) -> Vec3<T>
pub fn world_to_viewport_zo<V3>( obj: V3, modelview: Mat4<T>, proj: Mat4<T>, viewport: Rect<T, T>, ) -> Vec3<T>
Projects a world-space coordinate into screen space,
for a depth clip space ranging from 0 to 1 (GL_DEPTH_ZERO_TO_ONE
,
hence the _zo
suffix).
sourcepub fn viewport_to_world_zo<V3>(
ray: V3,
modelview: Mat4<T>,
proj: Mat4<T>,
viewport: Rect<T, T>,
) -> Vec3<T>
pub fn viewport_to_world_zo<V3>( ray: V3, modelview: Mat4<T>, proj: Mat4<T>, viewport: Rect<T, T>, ) -> Vec3<T>
Projects a screen-space coordinate into world space,
for a depth clip space ranging from 0 to 1 (GL_DEPTH_ZERO_TO_ONE
,
hence the _zo
suffix).
Trait Implementations§
source§impl<T> AbsDiffEq for Mat4<T>where
T: AbsDiffEq,
<T as AbsDiffEq>::Epsilon: Copy,
impl<T> AbsDiffEq for Mat4<T>where
T: AbsDiffEq,
<T as AbsDiffEq>::Epsilon: Copy,
source§fn default_epsilon() -> <T as AbsDiffEq>::Epsilon
fn default_epsilon() -> <T as AbsDiffEq>::Epsilon
source§fn abs_diff_eq(
&self,
other: &Mat4<T>,
epsilon: <Mat4<T> as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &Mat4<T>, epsilon: <Mat4<T> as AbsDiffEq>::Epsilon, ) -> bool
§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
].source§impl<T> AddAssign<T> for Mat4<T>
impl<T> AddAssign<T> for Mat4<T>
source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+=
operation. Read moresource§impl<T> AddAssign for Mat4<T>
impl<T> AddAssign for Mat4<T>
source§fn add_assign(&mut self, rhs: Mat4<T>)
fn add_assign(&mut self, rhs: Mat4<T>)
+=
operation. Read moresource§impl<T> Default for Mat4<T>
impl<T> Default for Mat4<T>
The default value for a square matrix is the identity.
assert_eq!(Mat4::<f32>::default(), Mat4::<f32>::identity());
source§impl<'de, T> Deserialize<'de> for Mat4<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Mat4<T>where
T: Deserialize<'de>,
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mat4<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mat4<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<T> Display for Mat4<T>where
T: Display,
impl<T> Display for Mat4<T>where
T: Display,
Displays this matrix using the following format:
(i
being the number of rows and j
the number of columns)
( m00 ... m0j
... ... ...
mi0 ... mij )
Note that elements are not comma-separated. This format doesn’t depend on the matrix’s storage layout.
source§impl<T> DivAssign<T> for Mat4<T>
impl<T> DivAssign<T> for Mat4<T>
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/=
operation. Read moresource§impl<T> DivAssign for Mat4<T>
impl<T> DivAssign for Mat4<T>
source§fn div_assign(&mut self, rhs: Mat4<T>)
fn div_assign(&mut self, rhs: Mat4<T>)
/=
operation. Read moresource§impl<T> From<Quaternion<T>> for Mat4<T>
impl<T> From<Quaternion<T>> for Mat4<T>
Rotation matrices can be obtained from quaternions. This implementation only works properly if the quaternion is normalized.
use std::f32::consts::PI;
let angles = 32;
for i in 0..angles {
let theta = PI * 2. * (i as f32) / (angles as f32);
assert_relative_eq!(Mat4::rotation_x(theta), Mat4::from(Quaternion::rotation_x(theta)), epsilon = 0.000001);
assert_relative_eq!(Mat4::rotation_y(theta), Mat4::from(Quaternion::rotation_y(theta)), epsilon = 0.000001);
assert_relative_eq!(Mat4::rotation_z(theta), Mat4::from(Quaternion::rotation_z(theta)), epsilon = 0.000001);
assert_relative_eq!(Mat4::rotation_x(theta), Mat4::rotation_3d(theta, Vec4::unit_x()));
assert_relative_eq!(Mat4::rotation_y(theta), Mat4::rotation_3d(theta, Vec4::unit_y()));
assert_relative_eq!(Mat4::rotation_z(theta), Mat4::rotation_3d(theta, Vec4::unit_z()));
// See what rotating unit vectors do for most angles between 0 and 2*PI.
// It's helpful to picture this as a right-handed coordinate system.
let v = Vec4::unit_y();
let m = Mat4::rotation_x(theta);
assert_relative_eq!(m * v, Vec4::new(0., theta.cos(), theta.sin(), 0.));
let v = Vec4::unit_z();
let m = Mat4::rotation_y(theta);
assert_relative_eq!(m * v, Vec4::new(theta.sin(), 0., theta.cos(), 0.));
let v = Vec4::unit_x();
let m = Mat4::rotation_z(theta);
assert_relative_eq!(m * v, Vec4::new(theta.cos(), theta.sin(), 0., 0.));
}
source§fn from(q: Quaternion<T>) -> Mat4<T>
fn from(q: Quaternion<T>) -> Mat4<T>
source§impl<T> From<Transform<T, T, T>> for Mat4<T>
impl<T> From<Transform<T, T, T>> for Mat4<T>
A Mat4
can be obtained from a Transform
, by rotating, then scaling, then
translating.
source§impl<T> Index<(usize, usize)> for Mat4<T>
impl<T> Index<(usize, usize)> for Mat4<T>
Index this matrix in a layout-agnostic way with an (i, j)
(row index, column index) tuple.
Matrices cannot be indexed by Vec2
s because that would be likely to cause confusion:
should x
be the row index (because it’s the first element) or the column index
(because it’s a horizontal position) ?
source§impl<T> Mul<CubicBezier3<T>> for Mat4<T>
impl<T> Mul<CubicBezier3<T>> for Mat4<T>
§type Output = CubicBezier3<T>
type Output = CubicBezier3<T>
*
operator.source§fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
fn mul(self, rhs: CubicBezier3<T>) -> CubicBezier3<T>
*
operation. Read moresource§impl<T> Mul<Mat4<T>> for Mat4<T>
impl<T> Mul<Mat4<T>> for Mat4<T>
Multiplies a column-major matrix with a row-major matrix.
use vek::mat::row_major::Mat4 as Rows4;
use vek::mat::column_major::Mat4 as Cols4;
let m = Cols4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 0, 1,
2, 3, 4, 5
);
let b = Rows4::from(m);
let r = Rows4::<u32>::new(
26, 32, 18, 24,
82, 104, 66, 88,
38, 56, 74, 92,
54, 68, 42, 56
);
assert_eq!(m * b, r);
assert_eq!(m * Rows4::<u32>::identity(), m.into());
assert_eq!(Cols4::<u32>::identity() * b, m.into());
source§impl<T> Mul<Mat4<T>> for Vec4<T>
impl<T> Mul<Mat4<T>> for Vec4<T>
Multiplies a row vector with a column-major matrix, giving a row vector.
use vek::mat::column_major::Mat4;
use vek::vec::Vec4;
let m = Mat4::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 0, 1,
2, 3, 4, 5
);
let v = Vec4::new(0, 1, 2, 3);
let r = Vec4::new(26, 32, 18, 24);
assert_eq!(v * m, r);
source§impl<T> Mul<QuadraticBezier3<T>> for Mat4<T>
impl<T> Mul<QuadraticBezier3<T>> for Mat4<T>
§type Output = QuadraticBezier3<T>
type Output = QuadraticBezier3<T>
*
operator.source§fn mul(self, rhs: QuadraticBezier3<T>) -> QuadraticBezier3<T>
fn mul(self, rhs: QuadraticBezier3<T>) -> QuadraticBezier3<T>
*
operation. Read moresource§impl<T> Mul<Vec4<T>> for Mat4<T>
impl<T> Mul<Vec4<T>> for Mat4<T>
Multiplies a column-major matrix with a column vector, giving a column vector.
With SIMD vectors, this is the most efficient way.
use vek::mat::column_major::Mat4;
use vek::vec::Vec4;
let m = Mat4::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 0, 1,
2, 3, 4, 5
);
let v = Vec4::new(0, 1, 2, 3);
let r = Vec4::new(14, 38, 12, 26);
assert_eq!(m * v, r);
source§impl<T> Mul for Mat4<T>
impl<T> Mul for Mat4<T>
Multiplies a column-major matrix with another.
use vek::mat::column_major::Mat4;
let m = Mat4::<u32>::new(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 0, 1,
2, 3, 4, 5
);
let r = Mat4::<u32>::new(
26, 32, 18, 24,
82, 104, 66, 88,
38, 56, 74, 92,
54, 68, 42, 56
);
assert_eq!(m * m, r);
assert_eq!(m, m * Mat4::<u32>::identity());
assert_eq!(m, Mat4::<u32>::identity() * m);
source§impl<T> MulAssign<T> for Mat4<T>
impl<T> MulAssign<T> for Mat4<T>
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*=
operation. Read moresource§impl<T> MulAssign for Mat4<T>
impl<T> MulAssign for Mat4<T>
source§fn mul_assign(&mut self, rhs: Mat4<T>)
fn mul_assign(&mut self, rhs: Mat4<T>)
*=
operation. Read moresource§impl<T> PartialEq for Mat4<T>where
T: PartialEq,
impl<T> PartialEq for Mat4<T>where
T: PartialEq,
source§impl<T> RelativeEq for Mat4<T>where
T: RelativeEq,
<T as AbsDiffEq>::Epsilon: Copy,
impl<T> RelativeEq for Mat4<T>where
T: RelativeEq,
<T as AbsDiffEq>::Epsilon: Copy,
source§fn default_max_relative() -> <T as AbsDiffEq>::Epsilon
fn default_max_relative() -> <T as AbsDiffEq>::Epsilon
source§fn relative_eq(
&self,
other: &Mat4<T>,
epsilon: <T as AbsDiffEq>::Epsilon,
max_relative: <T as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &Mat4<T>, epsilon: <T as AbsDiffEq>::Epsilon, max_relative: <T as AbsDiffEq>::Epsilon, ) -> bool
§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
].source§impl<T> RemAssign<T> for Mat4<T>
impl<T> RemAssign<T> for Mat4<T>
source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
%=
operation. Read moresource§impl<T> RemAssign for Mat4<T>
impl<T> RemAssign for Mat4<T>
source§fn rem_assign(&mut self, rhs: Mat4<T>)
fn rem_assign(&mut self, rhs: Mat4<T>)
%=
operation. Read moresource§impl<T> Serialize for Mat4<T>where
T: Serialize,
impl<T> Serialize for Mat4<T>where
T: Serialize,
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl<T> SubAssign<T> for Mat4<T>
impl<T> SubAssign<T> for Mat4<T>
source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read moresource§impl<T> SubAssign for Mat4<T>
impl<T> SubAssign for Mat4<T>
source§fn sub_assign(&mut self, rhs: Mat4<T>)
fn sub_assign(&mut self, rhs: Mat4<T>)
-=
operation. Read moresource§impl<T> UlpsEq for Mat4<T>where
T: UlpsEq,
<T as AbsDiffEq>::Epsilon: Copy,
impl<T> UlpsEq for Mat4<T>where
T: UlpsEq,
<T as AbsDiffEq>::Epsilon: Copy,
source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
impl<T> Copy for Mat4<T>where
T: Copy,
impl<T> Eq for Mat4<T>where
T: Eq,
impl<T> StructuralPartialEq for Mat4<T>
Auto Trait Implementations§
impl<T> Freeze for Mat4<T>where
T: Freeze,
impl<T> RefUnwindSafe for Mat4<T>where
T: RefUnwindSafe,
impl<T> Send for Mat4<T>where
T: Send,
impl<T> Sync for Mat4<T>where
T: Sync,
impl<T> Unpin for Mat4<T>where
T: Unpin,
impl<T> UnwindSafe for Mat4<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
§fn convert_into<F>(
&self,
_: F,
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§fn convert_from<F>(
data: <C as ConvertSaveload<M>>::Data,
_: F,
) -> Result<C, <C as ConvertSaveload<M>>::Error>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
source§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default
and panics on an error case.