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

Three Vector

Implementations

Returns a new ThreeVec from three f64s

Arguments
  • x0 - f64
  • x1 - f64
  • x2 - f64
Example
use calcify::ThreeVec;
let vec3 = ThreeVec::new(1.0,2.0,3.0);

Returns a new ThreeVec from a slice

Arguments
Example
use calcify::ThreeVec;
let vec3: ThreeVec = ThreeVec::from(&[1.0,1.0,1.0]);
Panics
  • slice length < 3

Returns a new ThreeVec with three random f64 from rand::Uniform between -1 and 1

Arguments
  • max - f64: The absolute maximum value of each individule componant of the constituent ThreeVec
Example
use calcify::ThreeVec;
let vec3 = ThreeVec::random(10.0);

Returns a reference to the first element of the vector

Example
use calcify::ThreeVec;
let vec3 = ThreeVec::new(1.0,2.0,3.0);
let element_zero: f64 = *vec3.x0();
assert_eq!(element_zero,1.0);

Returns a reference to the second element of the vector

Example
use calcify::ThreeVec;
let vec3 = ThreeVec::new(1.0,2.0,3.0);
let element_one: f64 = *vec3.x1();
assert_eq!(element_one,2.0);

Returns a reference to the third element of the vector

Example
use calcify::ThreeVec;
let vec3 = ThreeVec::new(1.0,2.0,3.0);
let element_two: f64 = *vec3.x2();
assert_eq!(element_two,3.0);

Returns the length of the vector

Example
use calcify::ThreeVec;
let vec3 = ThreeVec::new(1.0,0.0,0.0);
assert_eq!(vec3.r(),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

Dot product

Example
use calcify::ThreeVec;
let vec3 = ThreeVec::new(2.0,2.0,2.0);

assert_eq!(
   vec3*vec3,
   12.0
);

The resulting type after applying the * operator.

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

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.