[−][src]Struct calcify::FourVec
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
- f64m1
- f64m2
- f64m3
- 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
- f64x
- 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(&self) -> 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.
fn add(self, other: FourVec) -> FourVec
[src]
impl Sub<FourVec> for FourVec
[src]
type Output = FourVec
The resulting type after applying the -
operator.
fn sub(self, other: FourVec) -> FourVec
[src]
impl Mul<f64> for FourVec
[src]
type Output = FourVec
The resulting type after applying the *
operator.
fn mul(self, coef: f64) -> FourVec
[src]
impl Mul<FourVec> for f64
[src]
type Output = FourVec
The resulting type after applying the *
operator.
fn mul(self, vec: FourVec) -> FourVec
[src]
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]
impl AddAssign<FourVec> for FourVec
[src]
fn add_assign(&mut self, other: FourVec)
[src]
impl SubAssign<FourVec> for FourVec
[src]
fn sub_assign(&mut self, other: FourVec)
[src]
impl FromStr for FourVec
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?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>,