pub struct Vector3<T: CoordsFloat>(pub T, pub T, pub T);
Expand description
3D vector representation
§Generics
T: CoordsFloat
– Generic type for coordinates representation.
§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 three: f64 = 3.0;
let x_plus_y_plus_z: Vector3<f64> = unit_x + unit_y + unit_z;
assert_eq!(x_plus_y_plus_z.norm(), three.sqrt());
assert_eq!(x_plus_y_plus_z.unit_dir()?, Vector3(1.0 / three.sqrt(), 1.0 / three.sqrt(), 1.0 / three.sqrt()));
Tuple Fields§
§0: T
§1: T
§2: T
Implementations§
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§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>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<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>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.