pub struct FourVec { /* private fields */ }Expand description
Four Vector
Implementations§
Source§impl FourVec
impl FourVec
Sourcepub fn m0(&self) -> &f64
pub fn m0(&self) -> &f64
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);Sourcepub fn m1(&self) -> &f64
pub fn m1(&self) -> &f64
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);Sourcepub fn m2(&self) -> &f64
pub fn m2(&self) -> &f64
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);Sourcepub fn m3(&self) -> &f64
pub fn m3(&self) -> &f64
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);Sourcepub fn cov(self) -> FourVec
pub fn cov(self) -> FourVec
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)Trait Implementations§
Source§impl AddAssign for FourVec
impl AddAssign for FourVec
Source§fn add_assign(&mut self, other: FourVec)
fn add_assign(&mut self, other: FourVec)
Performs the
+= operation. Read moreSource§impl Deserializable for FourVec
impl Deserializable for FourVec
Source§impl Mul<FourVec> for FourMat
impl Mul<FourVec> for FourMat
Source§fn mul(self, other: FourVec) -> FourVec
fn mul(self, other: FourVec) -> FourVec
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)
);Source§impl Serializable for FourVec
impl Serializable for FourVec
Source§impl SubAssign for FourVec
impl SubAssign for FourVec
Source§fn sub_assign(&mut self, other: FourVec)
fn sub_assign(&mut self, other: FourVec)
Performs the
-= operation. Read moreimpl Copy for FourVec
impl StructuralPartialEq for FourVec
Auto Trait Implementations§
impl Freeze for FourVec
impl RefUnwindSafe for FourVec
impl Send for FourVec
impl Sync for FourVec
impl Unpin for FourVec
impl UnwindSafe for FourVec
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