pub struct Vector3<T: CoordsFloat>(pub T, pub T, pub T);Expand description
§3D vector structure
§Generics
T: CoordsFloat– Generic FP type for coordinates.
§Example
use honeycomb_core::geometry::Vector3;
let unit_x = Vector3::unit_x();
let unit_y = Vector3::unit_y();
let unit_z = Vector3::unit_z();
assert_eq!(unit_x.dot(&unit_y), 0.0);
assert_eq!(unit_x.cross(&unit_y), unit_z);
let sum: Vector3<f64> = unit_x + unit_y + unit_z;
assert_eq!(sum.norm(), 3.0_f64.sqrt());
assert_eq!(
sum.unit_dir()?,
Vector3(
1.0 / 3.0_f64.sqrt(),
1.0 / 3.0_f64.sqrt(),
1.0 / 3.0_f64.sqrt(),
),
);Tuple Fields§
§0: T§1: T§2: TImplementations§
Source§impl<T: CoordsFloat> Vector3<T>
impl<T: CoordsFloat> Vector3<T>
Sourcepub fn into_inner(self) -> (T, T, T)
pub fn into_inner(self) -> (T, T, T)
Consume self to return inner values.
Sourcepub fn unit_dir(&self) -> Result<Self, CoordsError>
pub fn unit_dir(&self) -> Result<Self, CoordsError>
Compute the direction of self as a unit vector.
§Errors
This method will return an error if called on a null Vector3.
Trait Implementations§
Source§impl<T: CoordsFloat> Add for Vector3<T>
impl<T: CoordsFloat> Add for Vector3<T>
Source§impl<T: CoordsFloat> AddAssign<&Vector3<T>> for Vertex3<T>
impl<T: CoordsFloat> AddAssign<&Vector3<T>> for Vertex3<T>
Source§fn add_assign(&mut self, rhs: &Vector3<T>)
fn add_assign(&mut self, rhs: &Vector3<T>)
Performs the
+= operation. Read moreSource§impl<T: CoordsFloat> AddAssign<Vector3<T>> for Vertex3<T>
impl<T: CoordsFloat> AddAssign<Vector3<T>> for Vertex3<T>
Source§fn add_assign(&mut self, rhs: Vector3<T>)
fn add_assign(&mut self, rhs: Vector3<T>)
Performs the
+= operation. Read moreSource§impl<T: CoordsFloat> AddAssign for Vector3<T>
impl<T: CoordsFloat> AddAssign for Vector3<T>
Source§fn add_assign(&mut self, rhs: Vector3<T>)
fn add_assign(&mut self, rhs: Vector3<T>)
Performs the
+= operation. Read moreSource§impl<T: CoordsFloat> Div<T> for Vector3<T>
impl<T: CoordsFloat> Div<T> for Vector3<T>
Source§impl<T: CoordsFloat> DivAssign<T> for Vector3<T>
impl<T: CoordsFloat> DivAssign<T> for Vector3<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/= operation. Read moreSource§impl<T: CoordsFloat> Mul<T> for Vector3<T>
impl<T: CoordsFloat> Mul<T> for Vector3<T>
Source§impl<T: CoordsFloat> MulAssign<T> for Vector3<T>
impl<T: CoordsFloat> MulAssign<T> for Vector3<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moreSource§impl<T: CoordsFloat> Neg for Vector3<T>
impl<T: CoordsFloat> Neg for Vector3<T>
Source§impl<T: CoordsFloat> Sub for Vector3<T>
impl<T: CoordsFloat> Sub for Vector3<T>
Source§impl<T: CoordsFloat> SubAssign<&Vector3<T>> for Vertex3<T>
impl<T: CoordsFloat> SubAssign<&Vector3<T>> for Vertex3<T>
Source§fn sub_assign(&mut self, rhs: &Vector3<T>)
fn sub_assign(&mut self, rhs: &Vector3<T>)
Performs the
-= operation. Read moreSource§impl<T: CoordsFloat> SubAssign<Vector3<T>> for Vertex3<T>
impl<T: CoordsFloat> SubAssign<Vector3<T>> for Vertex3<T>
Source§fn sub_assign(&mut self, rhs: Vector3<T>)
fn sub_assign(&mut self, rhs: Vector3<T>)
Performs the
-= operation. Read moreSource§impl<T: CoordsFloat> SubAssign for Vector3<T>
impl<T: CoordsFloat> SubAssign for Vector3<T>
Source§fn sub_assign(&mut self, rhs: Vector3<T>)
fn sub_assign(&mut self, rhs: Vector3<T>)
Performs the
-= operation. Read moreimpl<T: Copy + CoordsFloat> Copy for Vector3<T>
impl<T: CoordsFloat> Send for Vector3<T>
impl<T: CoordsFloat> StructuralPartialEq for Vector3<T>
impl<T: CoordsFloat> Sync for Vector3<T>
Auto Trait Implementations§
impl<T> Freeze for Vector3<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vector3<T>where
T: RefUnwindSafe,
impl<T> Unpin for Vector3<T>where
T: Unpin,
impl<T> UnwindSafe for Vector3<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more