pub struct Vertex2<T: CoordsFloat>(pub T, pub T);Expand description
§2D vertex structure
§Attribute behavior
- binds to 0-cells,
- merge policy: the new vertex is placed at the midpoint between the two existing ones,
- split policy: the current vertex is duplicated,
- fallback policies: default implementations are used.
§Generics
T: CoordsFloat– Generic FP type for coordinates.
§Example
use honeycomb_core::geometry::{Vector2, Vertex2};
let v1 = Vertex2(1.0, 0.0);
let v2 = Vertex2(1.0, 1.0);
assert_eq!(v1.x(), 1.0);
assert_eq!(v1.y(), 0.0);
let two: f64 = 2.0;
// vectorAB = vertexB - vertexA
let v2_minus_v1: Vector2<f64> = v2 - v1;
assert_eq!(v2_minus_v1.norm(), 1.0);
assert_eq!(v2_minus_v1.unit_dir()?, Vector2::unit_y());
let mut v3 = Vertex2(0.0, 1.0);
// vertexA + vectorB = vertexA'
v3 += v2_minus_v1;
assert_eq!(v3.x(), 0.0);
assert_eq!(v3.y(), 2.0);
Tuple Fields§
§0: T§1: TImplementations§
Source§impl<T: CoordsFloat> Vertex2<T>
impl<T: CoordsFloat> Vertex2<T>
Sourcepub fn into_inner(self) -> (T, T)
pub fn into_inner(self) -> (T, T)
Consume self to return inner values.
Sourcepub fn average(lhs: &Vertex2<T>, rhs: &Vertex2<T>) -> Vertex2<T>
pub fn average(lhs: &Vertex2<T>, rhs: &Vertex2<T>) -> Vertex2<T>
Compute the mid-point between two vertices.
§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::Vertex2;
let far_far_away: Vertex2<f64> = Vertex2(2.0, 2.0);
let origin: Vertex2<f64> = Vertex2::default();
assert_eq!(Vertex2::average(&origin, &far_far_away), Vertex2(1.0, 1.0));Sourcepub fn cross_product_from_vertices(v1: &Self, v2: &Self, v3: &Self) -> T
pub fn cross_product_from_vertices(v1: &Self, v2: &Self, v3: &Self) -> T
Compute the scalar component of the v1v2 x v2v3 cross product.
Trait Implementations§
Source§impl<T: CoordsFloat> AddAssign<&Vector2<T>> for Vertex2<T>
impl<T: CoordsFloat> AddAssign<&Vector2<T>> for Vertex2<T>
Source§fn add_assign(&mut self, rhs: &Vector2<T>)
fn add_assign(&mut self, rhs: &Vector2<T>)
Performs the
+= operation. Read moreSource§impl<T: CoordsFloat> AddAssign<Vector2<T>> for Vertex2<T>
impl<T: CoordsFloat> AddAssign<Vector2<T>> for Vertex2<T>
Source§fn add_assign(&mut self, rhs: Vector2<T>)
fn add_assign(&mut self, rhs: Vector2<T>)
Performs the
+= operation. Read moreSource§impl<T: CoordsFloat> AttributeBind for Vertex2<T>
impl<T: CoordsFloat> AttributeBind for Vertex2<T>
Source§const BIND_POLICY: OrbitPolicy = OrbitPolicy::Vertex
const BIND_POLICY: OrbitPolicy = OrbitPolicy::Vertex
OrbitPolicy determining the kind of topological entity to which the attribute
is associated.Source§type StorageType = AttrSparseVec<Vertex2<T>>
type StorageType = AttrSparseVec<Vertex2<T>>
Storage type used for the attribute.
Source§type IdentifierType = u32
type IdentifierType = u32
Identifier type of the entity the attribute is bound to.
Source§impl<T: CoordsFloat> AttributeUpdate for Vertex2<T>
impl<T: CoordsFloat> AttributeUpdate for Vertex2<T>
Source§fn merge(attr1: Self, attr2: Self) -> Result<Self, AttributeError>
fn merge(attr1: Self, attr2: Self) -> Result<Self, AttributeError>
Merging routine, i.e. how to obtain a new value from two existing ones. Read more
Source§fn split(attr: Self) -> Result<(Self, Self), AttributeError>
fn split(attr: Self) -> Result<(Self, Self), AttributeError>
Splitting routine, i.e. how to obtain the two new values from a single one. Read more
Source§fn merge_incomplete(attr: Self) -> Result<Self, AttributeError>
fn merge_incomplete(attr: Self) -> Result<Self, AttributeError>
Fallback merging routine, i.e. how to obtain a new value from a single existing one. Read more
Source§fn merge_from_none() -> Result<Self, AttributeError>
fn merge_from_none() -> Result<Self, AttributeError>
Fallback merging routine, i.e. how to obtain a new value from no existing one. Read more
Source§fn split_from_none() -> Result<(Self, Self), AttributeError>
fn split_from_none() -> Result<(Self, Self), AttributeError>
Fallback splitting routine, i.e. how to obtain two new values from no existing one. Read more
Source§impl<T: CoordsFloat> Sub for Vertex2<T>
impl<T: CoordsFloat> Sub for Vertex2<T>
Source§impl<T: CoordsFloat> SubAssign<&Vector2<T>> for Vertex2<T>
impl<T: CoordsFloat> SubAssign<&Vector2<T>> for Vertex2<T>
Source§fn sub_assign(&mut self, rhs: &Vector2<T>)
fn sub_assign(&mut self, rhs: &Vector2<T>)
Performs the
-= operation. Read moreSource§impl<T: CoordsFloat> SubAssign<Vector2<T>> for Vertex2<T>
impl<T: CoordsFloat> SubAssign<Vector2<T>> for Vertex2<T>
Source§fn sub_assign(&mut self, rhs: Vector2<T>)
fn sub_assign(&mut self, rhs: Vector2<T>)
Performs the
-= operation. Read moreimpl<T: Copy + CoordsFloat> Copy for Vertex2<T>
impl<T: CoordsFloat> Send for Vertex2<T>
impl<T: CoordsFloat> StructuralPartialEq for Vertex2<T>
impl<T: CoordsFloat> Sync for Vertex2<T>
Auto Trait Implementations§
impl<T> Freeze for Vertex2<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vertex2<T>where
T: RefUnwindSafe,
impl<T> Unpin for Vertex2<T>where
T: Unpin,
impl<T> UnwindSafe for Vertex2<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