[−][src]Struct batbox::Mat4
4x4 matrix
Methods
impl<T: Copy> Mat4<T>
[src]
pub fn transpose(self) -> Self
[src]
Get transposed matrix.
Examples
use batbox::*; let matrix = Mat4::translate(vec3(1, 2, 3)); let matrix_transposed = matrix.transpose(); for i in 0..4 { for j in 0..4 { assert_eq!(matrix[(i, j)], matrix_transposed[(j, i)]); } }
impl<T: Num> Mat4<T>
[src]
impl<T: Float> Mat4<T>
[src]
pub fn inverse(self) -> Self
[src]
Get inverse matrix.
Examples
use batbox::*; let matrix = Mat4::<f64>::rotate_x(0.123); let matrix_inv = matrix.inverse(); let mult = matrix * matrix_inv; for i in 0..4 { for j in 0..4 { assert!((mult[(i, j)] - if i == j { 1.0 } else { 0.0 }).abs() < 1e-5); } }
impl<T: Float> Mat4<T>
[src]
pub fn perspective(fov: T, aspect: T, near: T, far: T) -> Self
[src]
Construct prespective projection matrix.
pub fn frustum(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Self
[src]
Construct frustum projection matrix.
impl<T: Num + Copy> Mat4<T>
[src]
pub fn scale_uniform(factor: T) -> Self
[src]
Construct a uniform scale matrix.
Examples
use batbox::*; let matrix = Mat4::scale_uniform(2); assert_eq!(matrix * vec4(1, 2, 3, 1), vec4(2, 4, 6, 1));
pub fn scale(factor: Vec3<T>) -> Self
[src]
Construct a scale matrix.
Examples
use batbox::*; let matrix = Mat4::scale(vec3(1, 2, 3)); assert_eq!(matrix * vec4(1, 2, 3, 1), vec4(1, 4, 9, 1));
pub fn translate(dv: Vec3<T>) -> Self
[src]
Construct a translation matrix.
Examples
use batbox::*; let matrix = Mat4::translate(vec3(3, 2, 1)); assert_eq!(matrix * vec4(1, 2, 3, 1), vec4(4, 4, 4, 1));
impl<T: Float> Mat4<T>
[src]
pub fn rotate_x(angle: T) -> Self
[src]
Construct matrix rotating around x axis.
pub fn rotate_y(angle: T) -> Self
[src]
Construct matrix rotating around y axis.
pub fn rotate_z(angle: T) -> Self
[src]
Construct matrix rotating around z axis.
pub fn rotate(v: Vec3<T>, angle: T) -> Self where
T: SubAssign + AddAssign,
[src]
T: SubAssign + AddAssign,
impl<T> Mat4<T>
[src]
impl<T: Copy> Mat4<T>
[src]
pub fn new(values: [[T; 4]; 4]) -> Self
[src]
Construct a matrix.
Examples
use batbox::*; let matrix = Mat4::new([ [1, 2, 3, 4], [3, 4, 5, 6], [5, 6, 7, 8], [0, 5, 2, 9], ]);
pub fn row(&self, row_index: usize) -> Vec4<T>
[src]
impl<T> Mat4<T>
[src]
pub fn as_flat_array(&self) -> &[T; 16]
[src]
pub fn as_flat_array_mut(&mut self) -> &mut [T; 16]
[src]
impl<T: Num + Copy> Mat4<T>
[src]
pub fn zero() -> Self
[src]
Construct zero matrix.
Examples
use batbox::*; let matrix = Mat4::<i32>::zero(); for i in 0..4 { for j in 0..4 { assert_eq!(matrix[(i, j)], 0); } }
pub fn identity() -> Self
[src]
Construct identity matrix.
Examples
use batbox::*; let matrix = Mat4::<i32>::identity(); for i in 0..4 { for j in 0..4 { assert_eq!(matrix[(i, j)], if i == j { 1 } else { 0 }); } }
Trait Implementations
impl<T: Num + Copy> Add<Mat4<T>> for Mat4<T>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
impl<T: Num + Copy + AddAssign> AddAssign<Mat4<T>> for Mat4<T>
[src]
fn add_assign(&mut self, rhs: Self)
[src]
impl<T: Float> ApproxEq for Mat4<T>
[src]
fn approx_distance_to(&self, other: &Self) -> f32
[src]
fn approx_eq(&self, other: &Self) -> bool
[src]
fn approx_eq_eps(&self, other: &Self, eps: f32) -> bool
[src]
impl<T: Clone> Clone for Mat4<T>
[src]
impl<T: Copy> Copy for Mat4<T>
[src]
impl<T: Debug> Debug for Mat4<T>
[src]
impl<'de, T> Deserialize<'de> for Mat4<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T: Num + Copy> Div<T> for Mat4<T>
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Self
[src]
impl<T: Num + Copy + DivAssign> DivAssign<T> for Mat4<T>
[src]
fn div_assign(&mut self, rhs: T)
[src]
impl<T: Float> From<Quat<T>> for Mat4<T>
[src]
impl<T> Index<(usize, usize)> for Mat4<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, (row, col): (usize, usize)) -> &T
[src]
impl<T> IndexMut<(usize, usize)> for Mat4<T>
[src]
impl<T: Num + Copy + AddAssign> Mul<Mat4<T>> for Mat4<T>
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: Self) -> Self
[src]
impl<T: Num + Copy> Mul<T> for Mat4<T>
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self
[src]
impl<T: Num + Copy> Mul<Vec4<T>> for Mat4<T>
[src]
type Output = Vec4<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec4<T>) -> Vec4<T>
[src]
impl<T: Num + Copy + AddAssign> MulAssign<Mat4<T>> for Mat4<T>
[src]
fn mul_assign(&mut self, rhs: Self)
[src]
impl<T: Num + Copy + MulAssign> MulAssign<T> for Mat4<T>
[src]
fn mul_assign(&mut self, rhs: T)
[src]
impl<T: Num + Copy + Neg<Output = T>> Neg for Mat4<T>
[src]
impl<T> Serialize for Mat4<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<T: Num + Copy> Sub<Mat4<T>> for Mat4<T>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
impl<T: Num + Copy + SubAssign> SubAssign<Mat4<T>> for Mat4<T>
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Mat4<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Mat4<T> where
T: Send,
T: Send,
impl<T> Sync for Mat4<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Mat4<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Mat4<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,