pub struct Direction2(/* private fields */);Expand description
A unit vector in the plane.
Implementations§
Source§impl Direction2
impl Direction2
Sourcepub fn new(v: Vector2, tol: Tolerances) -> OgeomResult<Self>
pub fn new(v: Vector2, tol: Tolerances) -> OgeomResult<Self>
Normalize v into a direction.
§Errors
OgeomError::Construction if v is
non-finite or shorter than tol.confusion().
Sourcepub fn from_coords(x: f64, y: f64, tol: Tolerances) -> OgeomResult<Self>
pub fn from_coords(x: f64, y: f64, tol: Tolerances) -> OgeomResult<Self>
Sourcepub fn unit(v: Vector2, tol: Tolerances) -> OgeomResult<Self>
pub fn unit(v: Vector2, tol: Tolerances) -> OgeomResult<Self>
A direction from a vector that is already a unit vector.
As Direction::unit: it checks rather than normalizes, so a direction
read back from a document is the one that was written and not something
a bit or two away from it.
§Errors
OgeomError::Construction if v is
non-finite, or its length differs from one by more than
tol.confusion().
Sourcepub fn from_angle(angle: f64) -> Self
pub fn from_angle(angle: f64) -> Self
The direction at angle radians counter-clockwise from +X.
Sourcepub fn cross(self, other: Self) -> f64
pub fn cross(self, other: Self) -> f64
Scalar cross product: the sine of the signed angle from self to
other.
Sourcepub const fn perpendicular(self) -> Self
pub const fn perpendicular(self) -> Self
This direction rotated a quarter turn counter-clockwise. Exact.
Sourcepub fn angle(self, other: Self) -> f64
pub fn angle(self, other: Self) -> f64
Signed angle to other, in (-π, π], positive counter-clockwise.
Sourcepub fn is_equal(self, other: Self, tol: Tolerances) -> bool
pub fn is_equal(self, other: Self, tol: Tolerances) -> bool
Whether the two point the same way, within tol.angular().
Sourcepub fn is_opposite(self, other: Self, tol: Tolerances) -> bool
pub fn is_opposite(self, other: Self, tol: Tolerances) -> bool
Whether the two point opposite ways, within tol.angular().
Sourcepub fn is_parallel(self, other: Self, tol: Tolerances) -> bool
pub fn is_parallel(self, other: Self, tol: Tolerances) -> bool
Whether the two are parallel, ignoring sense.
Trait Implementations§
Source§impl Clone for Direction2
impl Clone for Direction2
Source§fn clone(&self) -> Direction2
fn clone(&self) -> Direction2
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Direction2
Source§impl Debug for Direction2
impl Debug for Direction2
Source§impl From<Direction2> for Vector2
impl From<Direction2> for Vector2
Source§fn from(d: Direction2) -> Self
fn from(d: Direction2) -> Self
Source§impl Mul<Direction2> for f64
impl Mul<Direction2> for f64
Source§impl Mul<f64> for Direction2
impl Mul<f64> for Direction2
Source§impl Neg for Direction2
impl Neg for Direction2
Source§impl PartialEq for Direction2
impl PartialEq for Direction2
Source§fn eq(&self, other: &Direction2) -> bool
fn eq(&self, other: &Direction2) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Direction2
Auto Trait Implementations§
impl Freeze for Direction2
impl RefUnwindSafe for Direction2
impl Send for Direction2
impl Sync for Direction2
impl Unpin for Direction2
impl UnsafeUnpin for Direction2
impl UnwindSafe for Direction2
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ClosedNeg for Twhere
T: Neg<Output = T>,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.