[][src]Struct calcify::ThreeMat

pub struct ThreeMat { /* fields omitted */ }

Three Matrix

Methods

impl ThreeMat[src]

pub fn new(r0: ThreeVec, r1: ThreeVec, r2: ThreeVec) -> ThreeMat[src]

Returns a new ThreeMat from three ThreeVecs

Arguments

  • r0 - calcify::ThreeVec
  • r1 - calcify::ThreeVec
  • r2 - calcify::ThreeVec

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)
           );

pub fn random(max: f64) -> ThreeMat[src]

Returns a new ThreeMat with three random ThreeVecs using calcify::ThreeVec::random(max: f64)

Arguments

  • max - f64: The absolute maximum value of each individule componant of the constituent ThreeVec

Example

use calcify::ThreeMat;
let mat3 = ThreeMat::random(10.0);

pub fn eye() -> ThreeMat[src]

Returns a new ThreeMat identity matrix

Example

use calcify::ThreeMat;
let mat3 = ThreeMat::eye();

assert_eq!(*mat3.r1().x1(),1.0);

pub fn zero() -> ThreeMat[src]

Returns a new ThreeMat zero matrix

Example

use calcify::ThreeMat;
let mat3 = ThreeMat::zero();

assert_eq!(*mat3.r1().x1(),0.0);

pub fn one() -> ThreeMat[src]

Returns a new ThreeMat one matrix

Example

use calcify::ThreeMat;
let mat3 = ThreeMat::one();

assert_eq!(*mat3.r1().x1(),1.0);

pub fn r0(&self) -> &ThreeVec[src]

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);

pub fn r1(&self) -> &ThreeVec[src]

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);

pub fn r2(&self) -> &ThreeVec[src]

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);

pub fn c0(&self) -> ThreeVec[src]

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[src]

pub fn c2(&self) -> ThreeVec[src]

Trait Implementations

impl Serializable for ThreeMat[src]

impl Clone for ThreeMat[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for ThreeMat[src]

impl PartialEq<ThreeMat> for ThreeMat[src]

impl Display for ThreeMat[src]

impl Debug for ThreeMat[src]

impl FromStr for ThreeMat[src]

type Err = ParseFloatError

The associated error which can be returned from parsing.

impl Add<ThreeMat> for ThreeMat[src]

type Output = ThreeMat

The resulting type after applying the + operator.

impl Sub<ThreeMat> for ThreeMat[src]

type Output = ThreeMat

The resulting type after applying the - operator.

impl Mul<f64> for ThreeMat[src]

type Output = ThreeMat

The resulting type after applying the * operator.

impl Mul<ThreeMat> for f64[src]

type Output = ThreeMat

The resulting type after applying the * operator.

impl Mul<ThreeMat> for ThreeMat[src]

type Output = ThreeMat

The resulting type after applying the * operator.

fn mul(self, other: ThreeMat) -> ThreeMat[src]

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)));

impl Mul<ThreeVec> for ThreeMat[src]

type Output = ThreeVec

The resulting type after applying the * operator.

fn mul(self, other: ThreeVec) -> ThreeVec[src]

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)
);

impl Neg for ThreeMat[src]

type Output = ThreeMat

The resulting type after applying the - operator.

impl AddAssign<ThreeMat> for ThreeMat[src]

impl SubAssign<ThreeMat> for ThreeMat[src]

Auto Trait Implementations

impl Send for ThreeMat

impl Sync for ThreeMat

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.