honeycomb_core::geometry

Struct Vertex3

Source
pub struct Vertex3<T: CoordsFloat>(pub T, pub T, pub T);
Expand description

3D vertex representation

§Generics

  • T: CoordsFloat – Generic type for coordinates representation.

§Example

use honeycomb_core::geometry::{Vector3, Vertex3};

let v1 = Vertex3(1.0, 0.0, 0.0);
let v2 = Vertex3(1.0, 1.0, 1.0);

assert_eq!(v1.x(), 1.0);
assert_eq!(v1.y(), 0.0);
assert_eq!(v1.z(), 0.0);

let two: f64 = 2.0;
// vectorAB = vertexB - vertexA
let v2_minus_v1: Vector3<f64> = v2 - v1;

assert_eq!(v2_minus_v1.norm(), two.sqrt());
assert_eq!(v2_minus_v1.unit_dir()?, Vector3(0.0, 1.0 / two.sqrt(), 1.0 / two.sqrt()));

let mut v3 = Vertex3(0.0, 1.0, 1.0);
// vertexA + vectorB = vertexA'
v3 += v2_minus_v1;

assert_eq!(v3.x(), 0.0);
assert_eq!(v3.y(), 2.0);
assert_eq!(v3.z(), 2.0);

Tuple Fields§

§0: T§1: T§2: T

Implementations§

Source§

impl<T: CoordsFloat> Vertex3<T>

Source

pub fn into_inner(self) -> (T, T, T)

Consume self to return inner value

§Return

Return coordinate values as a simple tuple.

Source

pub fn x(&self) -> T

Getter

§Return

Return the value of the x coordinate of the vertex.

Source

pub fn y(&self) -> T

Getter

§Return

Return the value of the y coordinate of the vertex.

Source

pub fn z(&self) -> T

Getter

§Return

Return the value of the z coordinate of the vertex.

Source

pub fn average(lhs: &Vertex3<T>, rhs: &Vertex3<T>) -> Vertex3<T>

Compute the mid-point between two vertices.

§Return

Return the mid-point as a new Vertex3 object.

§Panics

This function may panic if it cannot initialize an object T: CoordsFloat from the value 2.0. The chance of this happening when using T = f64 or T = f32 is most likely zero.

§Example
use honeycomb_core::geometry::Vertex3;

let far_far_away: Vertex3<f64> = Vertex3(2.0, 2.0, 2.0);
let origin: Vertex3<f64> = Vertex3::default();

assert_eq!(Vertex3::average(&origin, &far_far_away), Vertex3(1.0, 1.0, 1.0));

Trait Implementations§

Source§

impl<T: CoordsFloat> Add<&Vector3<T>> for Vertex3<T>

Source§

type Output = Vertex3<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Vector3<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: CoordsFloat> Add<Vector3<T>> for Vertex3<T>

Source§

type Output = Vertex3<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector3<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: CoordsFloat> AddAssign<&Vector3<T>> for Vertex3<T>

Source§

fn add_assign(&mut self, rhs: &Vector3<T>)

Performs the += operation. Read more
Source§

impl<T: CoordsFloat> AddAssign<Vector3<T>> for Vertex3<T>

Source§

fn add_assign(&mut self, rhs: Vector3<T>)

Performs the += operation. Read more
Source§

impl<T: CoordsFloat> AttributeBind for Vertex3<T>

Attribute support definitions

  • BINDS TO 0-CELLS
Source§

const BIND_POLICY: OrbitPolicy = OrbitPolicy::Vertex

OrbitPolicy determining the kind of topological entity to which the attribute is associated.
Source§

type StorageType = AttrSparseVec<Vertex3<T>>

Storage type used for the attribute.
Source§

type IdentifierType = u32

Identifier type of the entity the attribute is bound to.
Source§

impl<T: CoordsFloat> AttributeUpdate for Vertex3<T>

Attribute logic definitions

  • MERGING POLICY - The new vertex is placed at the midpoint between the two existing ones.
  • SPLITTING POLICY - The current vertex is duplicated.
  • (PARTIALLY) UNDEFINED ATTRIBUTES MERGING - The default implementations are used.
Source§

fn merge(attr1: Self, attr2: Self) -> Self

Merging routine, i.e. how to obtain the new attribute value from the two existing ones.
Source§

fn split(attr: Self) -> (Self, Self)

Splitting routine, i.e. how to obtain the two attributes from a single one.
Source§

fn merge_incomplete(attr: Self) -> Self

Fallback merging routine, i.e. how to obtain the new attribute value from a single existing value. Read more
Source§

fn merge_from_none() -> Option<Self>

Fallback merging routine, i.e. how to obtain the new attribute value from no existing value. Read more
Source§

impl<T: Clone + CoordsFloat> Clone for Vertex3<T>

Source§

fn clone(&self) -> Vertex3<T>

Returns a copy 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<T: Debug + CoordsFloat> Debug for Vertex3<T>

Source§

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

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

impl<T: Default + CoordsFloat> Default for Vertex3<T>

Source§

fn default() -> Vertex3<T>

Returns the “default value” for a type. Read more
Source§

impl<T: CoordsFloat> From<(T, T, T)> for Vertex3<T>

Source§

fn from((x, y, z): (T, T, T)) -> Self

Converts to this type from the input type.
Source§

impl<T: CoordsFloat> From<Vertex2<T>> for Vertex3<T>

Source§

fn from(v: Vertex2<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialEq + CoordsFloat> PartialEq for Vertex3<T>

Source§

fn eq(&self, other: &Vertex3<T>) -> 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<T: CoordsFloat> Sub<&Vector3<T>> for Vertex3<T>

Source§

type Output = Vertex3<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Vector3<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: CoordsFloat> Sub<Vector3<T>> for Vertex3<T>

Source§

type Output = Vertex3<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector3<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: CoordsFloat> Sub for Vertex3<T>

Source§

type Output = Vector3<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vertex3<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: CoordsFloat> SubAssign<&Vector3<T>> for Vertex3<T>

Source§

fn sub_assign(&mut self, rhs: &Vector3<T>)

Performs the -= operation. Read more
Source§

impl<T: CoordsFloat> SubAssign<Vector3<T>> for Vertex3<T>

Source§

fn sub_assign(&mut self, rhs: Vector3<T>)

Performs the -= operation. Read more
Source§

impl<T: Copy + CoordsFloat> Copy for Vertex3<T>

Source§

impl<T: CoordsFloat> Send for Vertex3<T>

Source§

impl<T: CoordsFloat> StructuralPartialEq for Vertex3<T>

Source§

impl<T: CoordsFloat> Sync for Vertex3<T>

Auto Trait Implementations§

§

impl<T> Freeze for Vertex3<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vertex3<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Vertex3<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vertex3<T>
where T: UnwindSafe,

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, dst: *mut u8)

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

impl<T> Downcast for T
where T: 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>

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)

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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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, 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.