ThreeVec

Struct ThreeVec 

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

Three Vector

Implementations§

Source§

impl ThreeVec

Source

pub fn new(x0: f64, x1: f64, x2: f64) -> ThreeVec

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

pub fn from(slice: &[f64]) -> ThreeVec

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
Source

pub fn random(max: f64) -> ThreeVec

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

pub fn x0(&self) -> &f64

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

pub fn x1(&self) -> &f64

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

pub fn x2(&self) -> &f64

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

pub fn r(&self) -> f64

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§

Source§

impl Add for ThreeVec

Source§

type Output = ThreeVec

The resulting type after applying the + operator.
Source§

fn add(self, other: ThreeVec) -> ThreeVec

Performs the + operation. Read more
Source§

impl AddAssign for ThreeVec

Source§

fn add_assign(&mut self, other: ThreeVec)

Performs the += operation. Read more
Source§

impl Clone for ThreeVec

Source§

fn clone(&self) -> ThreeVec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThreeVec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deserializable for ThreeVec

Source§

fn from_json(s: &str) -> Result<Self, Box<dyn Error>>

Return Self from string
Source§

fn from_msg(bytes: &[u8]) -> Result<(Self, &[u8]), Box<dyn Error>>

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

impl Display for ThreeVec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mul<ThreeVec> for ThreeMat

Source§

fn mul(self, other: ThreeVec) -> ThreeVec

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

type Output = ThreeVec

The resulting type after applying the * operator.
Source§

impl Mul<ThreeVec> for f64

Source§

type Output = ThreeVec

The resulting type after applying the * operator.
Source§

fn mul(self, vec: ThreeVec) -> ThreeVec

Performs the * operation. Read more
Source§

impl Mul<f64> for ThreeVec

Source§

type Output = ThreeVec

The resulting type after applying the * operator.
Source§

fn mul(self, coef: f64) -> ThreeVec

Performs the * operation. Read more
Source§

impl Mul for ThreeVec

Source§

fn mul(self, other: ThreeVec) -> f64

Dot product

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

assert_eq!(
   vec3*vec3,
   12.0
);
Source§

type Output = f64

The resulting type after applying the * operator.
Source§

impl Neg for ThreeVec

Source§

type Output = ThreeVec

The resulting type after applying the - operator.
Source§

fn neg(self) -> ThreeVec

Performs the unary - operation. Read more
Source§

impl PartialEq for ThreeVec

Source§

fn eq(&self, other: &ThreeVec) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serializable for ThreeVec

Source§

fn to_json(&self) -> String

Return object intensive json string Read more
Source§

fn to_msg(&self) -> Result<Vec<u8>, ValueWriteError>

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

impl Sub for ThreeVec

Source§

type Output = ThreeVec

The resulting type after applying the - operator.
Source§

fn sub(self, other: ThreeVec) -> ThreeVec

Performs the - operation. Read more
Source§

impl SubAssign for ThreeVec

Source§

fn sub_assign(&mut self, other: ThreeVec)

Performs the -= operation. Read more
Source§

impl Sum for ThreeVec

Source§

fn sum<I>(iter: I) -> ThreeVec
where I: Iterator<Item = ThreeVec>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Copy for ThreeVec

Source§

impl StructuralPartialEq for ThreeVec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.