[−][src]Struct calcify::FourMat
Four Matrix
Methods
impl FourMat
[src]
pub fn new(n0: FourVec, n1: FourVec, n2: FourVec, n3: FourVec) -> FourMat
[src]
Returns a new FourMat from four FourVecs
Arguments
n0
- calcify::FourVecn1
- calcify::FourVecn2
- calcify::FourVecn3
- calcify::FourVec
Example
use calcify::FourVec; use calcify::FourMat; let mat4 = FourMat::new( FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0) );
pub fn eye() -> FourMat
[src]
Returns a new FourMat identity matrix
Example
use calcify::FourMat; let mat4 = FourMat::eye(); assert_eq!(*mat4.n1().m1(),1.0);
pub fn zero() -> FourMat
[src]
Returns a new FourMat zero matrix
Example
use calcify::FourMat; let mat4 = FourMat::zero(); assert_eq!(*mat4.n1().m1(),0.0);
pub fn metric() -> FourMat
[src]
Returns a new FourMat metric tensor
Example
use calcify::FourMat; let mat4 = FourMat::metric(); assert_eq!(*mat4.n0().m0(),1.0); assert_eq!(*mat4.n1().m1(),-1.0); assert_eq!(*mat4.n2().m1(),0.0);
pub fn one() -> FourMat
[src]
Returns a new FourMat one matrix
Example
use calcify::FourMat; let mat4 = FourMat::one(); assert_eq!(*mat4.n1().m1(),1.0);
pub fn n0(&self) -> &FourVec
[src]
Returns a reference to the first row of the matrix.
Example
use calcify::FourVec; use calcify::FourMat; let mat4 = FourMat::new( FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0) ); let row_zero: FourVec = *mat4.n0(); let element_zero_zero: f64 = *mat4.n0().m0(); assert_eq!(row_zero,FourVec::new(1.0,2.0,3.0,4.0)); assert_eq!(element_zero_zero,1.0);
pub fn n1(&self) -> &FourVec
[src]
Returns a reference to the second row of the matrix.
Example
use calcify::FourVec; use calcify::FourMat; let mat4 = FourMat::new( FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0) ); let row_one: FourVec = *mat4.n1(); let element_one_one: f64 = *mat4.n1().m1(); assert_eq!(row_one,FourVec::new(5.0,6.0,7.0,8.0)); assert_eq!(element_one_one,6.0);
pub fn n2(&self) -> &FourVec
[src]
Returns a reference to the third row of the matrix.
Example
use calcify::FourVec; use calcify::FourMat; let mat4 = FourMat::new( FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0) ); let row_two: FourVec = *mat4.n2(); let element_two_two: f64 = *mat4.n2().m2(); assert_eq!(row_two,FourVec::new(9.0,10.0,11.0,12.0)); assert_eq!(element_two_two,11.0);
pub fn n3(&self) -> &FourVec
[src]
Returns a reference to the forth row of the matrix.
Example
use calcify::FourVec; use calcify::FourMat; let mat4 = FourMat::new( FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0) ); let row_three: FourVec = *mat4.n3(); let element_three_three: f64 = *mat4.n3().m3(); assert_eq!(row_three,FourVec::new(13.0,14.0,15.0,16.0)); assert_eq!(element_three_three,16.0);
pub fn c0(&self) -> FourVec
[src]
Returns a new memory FourVec of the first column of the matrix.
Example
use calcify::FourVec; use calcify::FourMat; let mat4 = FourMat::new( FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0) ); let col_one: FourVec = mat4.c0(); let element_one_one: f64 = *mat4.c0().m0(); assert_eq!(col_one,FourVec::new(1.0,5.0,9.0,13.0)); assert_eq!(element_one_one,1.0);
pub fn c1(&self) -> FourVec
[src]
pub fn c2(&self) -> FourVec
[src]
pub fn c3(&self) -> FourVec
[src]
Trait Implementations
impl Serializable for FourMat
[src]
impl Clone for FourMat
[src]
fn clone(&self) -> FourMat
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<FourMat> for FourMat
[src]
impl Copy for FourMat
[src]
impl Debug for FourMat
[src]
impl Display for FourMat
[src]
impl Add<FourMat> for FourMat
[src]
type Output = FourMat
The resulting type after applying the +
operator.
fn add(self, other: FourMat) -> FourMat
[src]
impl Sub<FourMat> for FourMat
[src]
type Output = FourMat
The resulting type after applying the -
operator.
fn sub(self, other: FourMat) -> FourMat
[src]
impl Mul<f64> for FourMat
[src]
type Output = FourMat
The resulting type after applying the *
operator.
fn mul(self, coef: f64) -> FourMat
[src]
impl Mul<FourMat> for f64
[src]
type Output = FourMat
The resulting type after applying the *
operator.
fn mul(self, vec: FourMat) -> FourMat
[src]
impl Mul<FourMat> for FourMat
[src]
type Output = FourMat
The resulting type after applying the *
operator.
fn mul(self, other: FourMat) -> FourMat
[src]
Matrix multiplication
Example
use calcify::FourMat; use calcify::FourVec; let mat4 = FourMat::new(FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(5.0,6.0,7.0,8.0), FourVec::new(9.0,10.0,11.0,12.0), FourVec::new(13.0,14.0,15.0,16.0)); assert_eq!( mat4*mat4, FourMat::new(FourVec::new(90.0,100.0,110.0,120.0), FourVec::new(202.0,228.0,254.0,280.0), FourVec::new(314.0,356.0,398.0,440.0), FourVec::new(426.0,484.0,542.0,600.0)));
impl Mul<FourVec> for FourMat
[src]
type Output = FourVec
The resulting type after applying the *
operator.
fn mul(self, other: FourVec) -> FourVec
[src]
Matrix multiplication with vector
Note
Only works in one direction FourMat*FourVec, implying FourVec as a column vector.
Example
use calcify::FourMat; use calcify::FourVec; let mat4 = FourMat::new(FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(1.0,2.0,3.0,4.0), FourVec::new(1.0,2.0,3.0,4.0)); assert_eq!( mat4*FourVec::new(2.0,2.0,2.0,2.0), FourVec::new(20.0,20.0,20.0,20.0) );
impl Neg for FourMat
[src]
impl AddAssign<FourMat> for FourMat
[src]
fn add_assign(&mut self, other: FourMat)
[src]
impl SubAssign<FourMat> for FourMat
[src]
fn sub_assign(&mut self, other: FourMat)
[src]
impl FromStr for FourMat
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,