Struct cavalier_contours::polyline::PlineVertex
source · pub struct PlineVertex<T = f64> {
pub x: T,
pub y: T,
pub bulge: T,
}
Expand description
A polyline vertex is represented by an x
, y
, and bulge
value.
x
and y
describe the 2D position of the vertex. bulge
describes the arc sweep angle for
the polyline segment that starts with this vertex. bulge
is defined as
tan(arc_sweep_angle / 4)
. Note a polyline arc segment can never have a sweep angle greater
than PI
(half circle).
See angle_from_bulge and bulge_from_angle for functions to convert between bulge arc sweep angle.
Fields§
§x: T
X coordinate position for the vertex.
y: T
Y coordinate position for the vertex.
bulge: T
Bulge for the polyline segment that starts with this vertex.
Implementations§
source§impl<T> PlineVertex<T>where
T: Real,
impl<T> PlineVertex<T>where
T: Real,
pub fn new(x: T, y: T, bulge: T) -> Self
sourcepub fn from_slice(slice: &[T]) -> Option<Self>
pub fn from_slice(slice: &[T]) -> Option<Self>
Construct a vertex from a [x, y, bulge] slice.
If the slice does not contain exactly 3 elements then None
is returned.
sourcepub fn from_vector2(vector2: Vector2<T>, bulge: T) -> Self
pub fn from_vector2(vector2: Vector2<T>, bulge: T) -> Self
Construct a vertex using a 2D vector as the position.
sourcepub fn with_bulge(&self, bulge: T) -> Self
pub fn with_bulge(&self, bulge: T) -> Self
Create a copy of the vertex with new bulge value but same x
and y
values.
sourcepub fn bulge_is_zero(&self) -> bool
pub fn bulge_is_zero(&self) -> bool
Returns true if self.bulge.fuzzy_eq_zero()
(represents the start of a line segment).
sourcepub fn bulge_is_pos(&self) -> bool
pub fn bulge_is_pos(&self) -> bool
Returns true if self.bulge > T::zero()
(represents the start of a counter clockwise arc
segment).
sourcepub fn bulge_is_neg(&self) -> bool
pub fn bulge_is_neg(&self) -> bool
Returns true if self.bulge < T::zero()
(represents the start of a clockwise arc segment).
sourcepub fn fuzzy_eq_eps(&self, other: Self, fuzzy_epsilon: T) -> bool
pub fn fuzzy_eq_eps(&self, other: Self, fuzzy_epsilon: T) -> bool
Fuzzy equal comparison with another vertex using fuzzy_epsilon
given.
Trait Implementations§
source§impl<T: Clone> Clone for PlineVertex<T>
impl<T: Clone> Clone for PlineVertex<T>
source§fn clone(&self) -> PlineVertex<T>
fn clone(&self) -> PlineVertex<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for PlineVertex<T>
impl<T: Debug> Debug for PlineVertex<T>
source§impl<T: Default> Default for PlineVertex<T>
impl<T: Default> Default for PlineVertex<T>
source§fn default() -> PlineVertex<T>
fn default() -> PlineVertex<T>
source§impl<T> Display for PlineVertex<T>where
T: Display,
impl<T> Display for PlineVertex<T>where
T: Display,
source§impl<T: PartialEq> PartialEq for PlineVertex<T>
impl<T: PartialEq> PartialEq for PlineVertex<T>
source§fn eq(&self, other: &PlineVertex<T>) -> bool
fn eq(&self, other: &PlineVertex<T>) -> bool
self
and other
values to be equal, and is used
by ==
.