[][src]Struct calcify::FourVec

pub struct FourVec { /* fields omitted */ }

Four Vector

Methods

impl FourVec[src]

pub fn new(m0: f64, m1: f64, m2: f64, m3: f64) -> FourVec[src]

Returns a new FourVec from four f64s

Arguments

  • m0 - f64
  • m1 - f64
  • m2 - f64
  • m3 - f64

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,2.0,3.0,4.0);

pub fn from_3vec(t: f64, x: ThreeVec) -> FourVec[src]

Returns a new FourVec from one f64 and a ThreeVec

Arguments

  • t - f64
  • x - calcify::ThreeVec

Example

use calcify::FourVec;
use calcify::ThreeVec;

let vec4 = FourVec::from_3vec(1.0,ThreeVec::new(2.0,3.0,4.0));

pub fn m0(&self) -> &f64[src]

Returns a reference to the first element of the vector

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,2.0,3.0,4.0);
let element_zero: f64 = *vec4.m0();
assert_eq!(element_zero,1.0);

pub fn m1(&self) -> &f64[src]

Returns a reference to the second element of the vector

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,2.0,3.0,4.0);
let element_one: f64 = *vec4.m1();
assert_eq!(element_one,2.0);

pub fn m2(&self) -> &f64[src]

Returns a reference to the third element of the vector

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,2.0,3.0,4.0);
let element_two: f64 = *vec4.m2();
assert_eq!(element_two,3.0);

pub fn m3(&self) -> &f64[src]

Returns a reference to the forth element of the vector

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,2.0,3.0,4.0);
let element_three: f64 = *vec4.m3();
assert_eq!(element_three,4.0);

pub fn cov(self) -> FourVec[src]

Returns the covariant vector with metric [1,-1,-1,-1].

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,2.0,3.0,4.0);
let cov_vec4: FourVec = vec4.cov();
assert_eq!(cov_vec4,FourVec::new(1.0,-2.0,-3.0,-4.0));

assert_eq!(vec4.cov()*vec4, -28.0)

pub fn s2(&self) -> Sinv[src]

Returns the space-time invariant classification S^2 of a space-time vector. Returns a variant of the calcify::Sinv enum

Example

use calcify::FourVec;
use calcify::Sinv;
let vec4 = FourVec::new(10.0,2.0,2.0,2.0);
let ss: Sinv = vec4.s2();
assert_eq!(ss,Sinv::TimeLike);

pub fn s(&self) -> f64[src]

Returns the invariant of the FourVec.

Example

use calcify::FourVec;
let vec4 = FourVec::new(1.0,0.0,0.0,0.0);
assert_eq!(vec4.s(),1.0);

Trait Implementations

impl Serializable for FourVec[src]

impl PartialEq<FourVec> for FourVec[src]

impl Clone for FourVec[src]

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

Performs copy-assignment from source. Read more

impl Copy for FourVec[src]

impl Debug for FourVec[src]

impl Display for FourVec[src]

impl Add<FourVec> for FourVec[src]

type Output = FourVec

The resulting type after applying the + operator.

impl Sub<FourVec> for FourVec[src]

type Output = FourVec

The resulting type after applying the - operator.

impl Mul<f64> for FourVec[src]

type Output = FourVec

The resulting type after applying the * operator.

impl Mul<FourVec> for f64[src]

type Output = FourVec

The resulting type after applying the * operator.

impl Mul<FourVec> for FourVec[src]

type Output = f64

The resulting type after applying the * operator.

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

Standard scalar product,

Example

use calcify::FourVec;
let vec4 = FourVec::new(2.0,2.0,2.0,2.0);

assert_eq!(
   vec4*vec4,
   16.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 FourVec[src]

type Output = FourVec

The resulting type after applying the - operator.

impl AddAssign<FourVec> for FourVec[src]

impl SubAssign<FourVec> for FourVec[src]

impl FromStr for FourVec[src]

type Err = ParseFloatError

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for FourVec

impl Sync for FourVec

Blanket Implementations

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

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, 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.