pub struct ThreeMat { /* private fields */ }Expand description
Three Matrix
Implementations§
Source§impl ThreeMat
impl ThreeMat
Sourcepub fn eye() -> ThreeMat
pub fn eye() -> ThreeMat
Returns a new ThreeMat identity matrix
§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::eye();
assert_eq!(*mat3.r1().x1(),1.0);Sourcepub fn zero() -> ThreeMat
pub fn zero() -> ThreeMat
Returns a new ThreeMat zero matrix
§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::zero();
assert_eq!(*mat3.r1().x1(),0.0);Sourcepub fn one() -> ThreeMat
pub fn one() -> ThreeMat
Returns a new ThreeMat one matrix
§Example
use calcify::ThreeMat;
let mat3 = ThreeMat::one();
assert_eq!(*mat3.r1().x1(),1.0);Sourcepub fn r0(&self) -> &ThreeVec
pub fn r0(&self) -> &ThreeVec
Returns a reference to the first row of the matrix.
§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(4.0,5.0,6.0),
ThreeVec::new(7.0,8.0,9.0)
);
let row_zero: ThreeVec = *mat3.r0();
let element_zero_zero: f64 = *mat3.r0().x0();
assert_eq!(row_zero,ThreeVec::new(1.0,2.0,3.0));
assert_eq!(element_zero_zero,1.0);Sourcepub fn r1(&self) -> &ThreeVec
pub fn r1(&self) -> &ThreeVec
Returns a reference to the second row of the matrix.
§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(4.0,5.0,6.0),
ThreeVec::new(7.0,8.0,9.0)
);
let row_one: ThreeVec = *mat3.r1();
let element_one_one: f64 = *mat3.r1().x1();
assert_eq!(row_one,ThreeVec::new(4.0,5.0,6.0));
assert_eq!(element_one_one,5.0);Sourcepub fn r2(&self) -> &ThreeVec
pub fn r2(&self) -> &ThreeVec
Returns a reference to the third row of the matrix.
§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(4.0,5.0,6.0),
ThreeVec::new(7.0,8.0,9.0)
);
let row_two: ThreeVec = *mat3.r2();
let element_two_two: f64 = *mat3.r2().x2();
assert_eq!(row_two,ThreeVec::new(7.0,8.0,9.0));
assert_eq!(element_two_two,9.0);Sourcepub fn c0(&self) -> ThreeVec
pub fn c0(&self) -> ThreeVec
Returns a new memory ThreeVec of the first column of the matrix.
§Example
use calcify::ThreeVec;
use calcify::ThreeMat;
let mat3 = ThreeMat::new(
ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(4.0,5.0,6.0),
ThreeVec::new(7.0,8.0,9.0)
);
let col_one: ThreeVec = mat3.c0();
let element_one_one: f64 = *mat3.c0().x0();
assert_eq!(col_one,ThreeVec::new(1.0,4.0,7.0));
assert_eq!(element_one_one,1.0);pub fn c1(&self) -> ThreeVec
pub fn c2(&self) -> ThreeVec
Trait Implementations§
Source§impl AddAssign for ThreeMat
impl AddAssign for ThreeMat
Source§fn add_assign(&mut self, other: ThreeMat)
fn add_assign(&mut self, other: ThreeMat)
Performs the
+= operation. Read moreSource§impl Deserializable for ThreeMat
impl Deserializable for ThreeMat
Source§impl Mul<ThreeVec> for ThreeMat
impl Mul<ThreeVec> for ThreeMat
Source§fn mul(self, other: ThreeVec) -> ThreeVec
fn mul(self, other: ThreeVec) -> ThreeVec
Matrix multiplication with vector
§Note
Only works in one direction ThreeMat*ThreeVec, implying ThreeVec as a column vector.
§Example
use calcify::ThreeMat;
use calcify::ThreeVec;
let mat3 = ThreeMat::new(ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(1.0,2.0,3.0));
assert_eq!(
mat3*ThreeVec::new(2.0,2.0,2.0),
ThreeVec::new(12.0,12.0,12.0)
);Source§impl Mul for ThreeMat
impl Mul for ThreeMat
Source§fn mul(self, other: ThreeMat) -> ThreeMat
fn mul(self, other: ThreeMat) -> ThreeMat
Matrix multiplication
§Example
use calcify::ThreeMat;
use calcify::ThreeVec;
let mat3 = ThreeMat::new(ThreeVec::new(1.0,2.0,3.0),
ThreeVec::new(4.0,5.0,6.0),
ThreeVec::new(7.0,8.0,9.0));
assert_eq!(
mat3*mat3,
ThreeMat::new(ThreeVec::new(30.0,36.0,42.0),
ThreeVec::new(66.0,81.0,96.0),
ThreeVec::new(102.0,126.0,150.0)));Source§impl Serializable for ThreeMat
impl Serializable for ThreeMat
Source§impl SubAssign for ThreeMat
impl SubAssign for ThreeMat
Source§fn sub_assign(&mut self, other: ThreeMat)
fn sub_assign(&mut self, other: ThreeMat)
Performs the
-= operation. Read moreimpl Copy for ThreeMat
impl StructuralPartialEq for ThreeMat
Auto Trait Implementations§
impl Freeze for ThreeMat
impl RefUnwindSafe for ThreeMat
impl Send for ThreeMat
impl Sync for ThreeMat
impl Unpin for ThreeMat
impl UnwindSafe for ThreeMat
Blanket Implementations§
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
Mutably borrows from an owned value. Read more