pub struct FourVec { /* private fields */ }
Expand description

Four Vector

Implementations

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

Returns a new FourVec from a slice

Arguments
Example
use calcify::FourVec;
let vec4: FourVec = FourVec::from(&[1.0,1.0,1.0,1.0]);
Panics
  • slice length < 4

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

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

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

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

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

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)

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

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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Return Self from string

Return a tuple of Self and a &u8 of remaining unparsed bytes from a byte array

Formats the value using the given formatter. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

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

The resulting type after applying the * operator.

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

The resulting type after applying the * operator.

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Return object intensive json string Read more

Return Result wrapped Vec in MsgPack Format is not like to_json it is array intensive not object Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

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

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.