[−][src]Struct vex::Matrix2
Fields
m: [f32; 4]
Methods
impl Matrix2
[src]
pub fn new() -> Matrix2
[src]
Creates a matrix set to its identity
Examples
use vex::Matrix2; let actual = Matrix2::new(); assert_eq!(actual.m, [ 1.0, 0.0, 0.0, 1.0, ]);
pub fn make(m11: f32, m21: f32, m12: f32, m22: f32) -> Matrix2
[src]
Creates a matrix from the provided values
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); let expected = [1.0, 2.0, 3.0, 4.0]; assert_eq!(actual.m, expected);
pub fn m11(&self) -> f32
[src]
Gets the value for the m11 element
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); assert_eq!(actual.m11(), 1.0);
pub fn m21(&self) -> f32
[src]
Gets the value for the m21 element
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); assert_eq!(actual.m21(), 2.0);
pub fn m12(&self) -> f32
[src]
Gets the value for the m12 element
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); assert_eq!(actual.m12(), 3.0);
pub fn m22(&self) -> f32
[src]
Gets the value for the m22 element
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); assert_eq!(actual.m22(), 4.0);
pub fn set_m11(&mut self, v: f32)
[src]
Sets the value for the m11 element
Examples
use vex::Matrix2; let mut actual = Matrix2::make(0.0, 0.0, 0.0, 0.0); actual.set_m11(1.0); let expected = [1.0, 0.0, 0.0, 0.0]; assert_eq!(actual.m, expected);
pub fn set_m21(&mut self, v: f32)
[src]
Sets the value for the m21 element
Examples
use vex::Matrix2; let mut actual = Matrix2::make(0.0, 0.0, 0.0, 0.0); actual.set_m21(1.0); let expected = [0.0, 1.0, 0.0, 0.0]; assert_eq!(actual.m, expected);
pub fn set_m12(&mut self, v: f32)
[src]
Sets the value for the m12 element
Examples
use vex::Matrix2; let mut actual = Matrix2::make(0.0, 0.0, 0.0, 0.0); actual.set_m12(1.0); let expected = [0.0, 0.0, 1.0, 0.0]; assert_eq!(actual.m, expected);
pub fn set_m22(&mut self, v: f32)
[src]
Sets the value for the m22 element
Examples
use vex::Matrix2; let mut actual = Matrix2::make(0.0, 0.0, 0.0, 0.0); actual.set_m22(1.0); let expected = [0.0, 0.0, 0.0, 1.0]; assert_eq!(actual.m, expected);
pub fn set(&mut self, m11: f32, m21: f32, m12: f32, m22: f32)
[src]
Sets the internal contents of the matrix
Examples
use vex::Matrix2; let mut actual = Matrix2::new(); actual.set(1.0, 2.0, 3.0, 4.0); let expected = Matrix2::make(1.0, 2.0, 3.0, 4.0); assert_eq!(actual, expected);
pub fn transpose(&mut self)
[src]
Transposes the matrix's elements
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual.transpose(); let expected = Matrix2::make(1.0, 3.0, 2.0, 4.0); assert_eq!(actual, expected);
pub fn determinant(&self) -> f32
[src]
Find the matrix's determinant
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0).determinant(); assert_eq!(actual, -2.0);
pub fn inverse(&mut self) -> bool
[src]
Inverses the matrix
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual.inverse(); let expected = Matrix2::make(-2.0, 1.0, 1.5, -0.5); assert_eq!(actual, expected);
pub fn is_valid(&self) -> bool
[src]
Determine whether or not all elements of the matrix are valid
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); assert!(actual.is_valid());
Trait Implementations
impl Add<Matrix2> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the +
operator.
fn add(self, _rhs: Matrix2) -> Matrix2
[src]
Add two matrices
Examples
use vex::Matrix2; let a = Matrix2::make(1.0, 2.0, 3.0, 4.0); let b = Matrix2::make(5.0, 6.0, 7.0, 8.0); let actual = a + b; let expected = Matrix2::make(6.0, 8.0, 10.0, 12.0); assert_eq!(actual, expected);
impl Add<f32> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the +
operator.
fn add(self, _rhs: f32) -> Matrix2
[src]
Find the resulting matrix by adding a scalar to a matrix's elements
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0) + 1.0; let expected = Matrix2::make(2.0, 3.0, 4.0, 5.0); assert_eq!(actual, expected);
impl AddAssign<Matrix2> for Matrix2
[src]
fn add_assign(&mut self, _rhs: Matrix2)
[src]
Increment a matrix by another matrix
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual += Matrix2::make(1.0, 2.0, 3.0, 4.0); let expected = Matrix2::make(2.0, 4.0, 6.0, 8.0); assert_eq!(actual, expected);
impl AddAssign<f32> for Matrix2
[src]
fn add_assign(&mut self, _rhs: f32)
[src]
Increment a matrix by a scalar
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual += 10.0; let expected = Matrix2::make(11.0, 12.0, 13.0, 14.0); assert_eq!(actual, expected);
impl Clone for Matrix2
[src]
impl Copy for Matrix2
[src]
impl Debug for Matrix2
[src]
impl Display for Matrix2
[src]
impl Div<f32> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the /
operator.
fn div(self, _rhs: f32) -> Matrix2
[src]
Find the resulting matrix by dividing a scalar to a matrix's elements
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0) / 2.0; let expected = Matrix2::make(0.5, 1.0, 1.5, 2.0); assert_eq!(actual, expected);
impl DivAssign<f32> for Matrix2
[src]
fn div_assign(&mut self, _rhs: f32)
[src]
Divide a matrix by a scalar
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual /= 2.0; let expected = Matrix2::make(0.5, 1.0, 1.5, 2.0); assert_eq!(actual, expected);
impl Matrix<Vector2> for Matrix2
[src]
fn transform_point(&self, point: &Vector2) -> Vector2
[src]
Find the resulting vector given a vector and matrix
Examples
use vex::Matrix; use vex::Matrix2; use vex::Vector2; let m = Matrix2::make(1.0, 2.0, 3.0, 4.0); let v = Vector2::make(1.0, 2.0); let actual = m.transform_point(&v); let expected = Vector2::make(7.0, 10.0); assert_eq!(actual, expected);
impl Mul<Matrix2> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the *
operator.
fn mul(self, _rhs: Matrix2) -> Matrix2
[src]
Multiply two matrices
Examples
use vex::Matrix2; let a = Matrix2::make(1.0, 2.0, 3.0, 4.0); let b = Matrix2::make(5.0, 6.0, 7.0, 8.0); let actual = a * b; let expected = Matrix2::make(23.0, 34.0, 31.0, 46.0); assert_eq!(actual, expected);
impl Mul<f32> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the *
operator.
fn mul(self, _rhs: f32) -> Matrix2
[src]
Find the resulting matrix by multiplying a scalar to a matrix's elements
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0) * 2.0; let expected = Matrix2::make(2.0, 4.0, 6.0, 8.0); assert_eq!(actual, expected);
impl MulAssign<Matrix2> for Matrix2
[src]
fn mul_assign(&mut self, _rhs: Matrix2)
[src]
Multiply a matrix by another matrix
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual *= Matrix2::make(5.0, 6.0, 7.0, 8.0); let expected = Matrix2::make(23.0, 34.0, 31.0, 46.0); assert_eq!(actual, expected);
impl MulAssign<f32> for Matrix2
[src]
fn mul_assign(&mut self, _rhs: f32)
[src]
Multiply a matrix by a scalar
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual *= 2.0; let expected = Matrix2::make(2.0, 4.0, 6.0, 8.0); assert_eq!(actual, expected);
impl Neg for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the -
operator.
fn neg(self) -> Matrix2
[src]
Negates the matrix's elements
Examples
use vex::Matrix2; let actual = -Matrix2::make(1.0, 2.0, 3.0, 4.0); let expected = Matrix2::make(-1.0, -2.0, -3.0, -4.0); assert_eq!(actual, expected);
impl PartialEq<Matrix2> for Matrix2
[src]
fn eq(&self, _rhs: &Matrix2) -> bool
[src]
Determines if two matrices' elements are equivalent
Examples
use vex::Matrix2; assert!(Matrix2::new() == Matrix2::new());
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Sub<Matrix2> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the -
operator.
fn sub(self, _rhs: Matrix2) -> Matrix2
[src]
Subtract two matrices
Examples
use vex::Matrix2; let a = Matrix2::make(1.0, 2.0, 3.0, 4.0); let b = Matrix2::make(5.0, 4.0, 3.0, 2.0); let actual = a - b; let expected = Matrix2::make(-4.0, -2.0, 0.0, 2.0); assert_eq!(actual, expected);
impl Sub<f32> for Matrix2
[src]
type Output = Matrix2
The resulting type after applying the -
operator.
fn sub(self, _rhs: f32) -> Matrix2
[src]
Find the resulting matrix by subtracting a scalar from a matrix's elements
Examples
use vex::Matrix2; let actual = Matrix2::make(1.0, 2.0, 3.0, 4.0) - 10.0; let expected = Matrix2::make(-9.0, -8.0, -7.0, -6.0); assert_eq!(actual, expected);
impl SubAssign<Matrix2> for Matrix2
[src]
fn sub_assign(&mut self, _rhs: Matrix2)
[src]
Decrement a matrix by another matrix
Examples
use vex::Matrix2; let mut actual = Matrix2::make(2.0, 2.0, 3.0, 5.0); actual -= Matrix2::make(1.0, 2.0, 3.0, 4.0); assert_eq!(actual, Matrix2::new());
impl SubAssign<f32> for Matrix2
[src]
fn sub_assign(&mut self, _rhs: f32)
[src]
Decrement a matrix by a scalar
Examples
use vex::Matrix2; let mut actual = Matrix2::make(1.0, 2.0, 3.0, 4.0); actual -= 1.0; let expected = Matrix2::make(0.0, 1.0, 2.0, 3.0); assert_eq!(actual, expected);
Auto Trait Implementations
impl RefUnwindSafe for Matrix2
impl Send for Matrix2
impl Sync for Matrix2
impl Unpin for Matrix2
impl UnwindSafe for Matrix2
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> 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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,