pub struct CoordOffset {
pub x: f64,
pub y: f64,
}Expand description
A 2D vector/displacement.
CoordOffset represents the difference between two Coord2D points.
It supports vector arithmetic: addition, subtraction, scalar multiplication,
negation, normalization, and dot products.
Fields§
§x: f64§y: f64Implementations§
Source§impl CoordOffset
impl CoordOffset
Sourcepub fn empty() -> CoordOffset
pub fn empty() -> CoordOffset
Zero vector (0, 0).
Sourcepub fn length_squared(&self) -> f64
pub fn length_squared(&self) -> f64
Squared length (avoids the sqrt).
Sourcepub fn normalize(&self) -> CoordOffset
pub fn normalize(&self) -> CoordOffset
Unit vector in the same direction. Returns zero if length is near-zero.
Sourcepub fn dot(&self, other: CoordOffset) -> f64
pub fn dot(&self, other: CoordOffset) -> f64
Dot product with another vector.
Sourcepub fn lerp(&self, other: CoordOffset, t: f64) -> CoordOffset
pub fn lerp(&self, other: CoordOffset, t: f64) -> CoordOffset
Linearly interpolate toward other by factor t (clamped 0..1).
Sourcepub fn min(&self, other: CoordOffset) -> CoordOffset
pub fn min(&self, other: CoordOffset) -> CoordOffset
Componentwise minimum.
Sourcepub fn max(&self, other: CoordOffset) -> CoordOffset
pub fn max(&self, other: CoordOffset) -> CoordOffset
Componentwise maximum.
Trait Implementations§
Source§impl Add for CoordOffset
impl Add for CoordOffset
Source§type Output = CoordOffset
type Output = CoordOffset
The resulting type after applying the
+ operator.Source§fn add(self, rhs: CoordOffset) -> CoordOffset
fn add(self, rhs: CoordOffset) -> CoordOffset
Performs the
+ operation. Read moreSource§impl Add<CoordOffset> for Coord2D
impl Add<CoordOffset> for Coord2D
Source§impl Clone for CoordOffset
impl Clone for CoordOffset
Source§fn clone(&self) -> CoordOffset
fn clone(&self) -> CoordOffset
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Components<f64, 2> for CoordOffset
impl Components<f64, 2> for CoordOffset
impl Copy for CoordOffset
Source§impl Debug for CoordOffset
impl Debug for CoordOffset
Source§impl From<CoordOffset> for [f64; 2]
impl From<CoordOffset> for [f64; 2]
Source§fn from(v: CoordOffset) -> Self
fn from(v: CoordOffset) -> Self
Converts to this type from the input type.
Source§impl Mul<f64> for CoordOffset
impl Mul<f64> for CoordOffset
Source§type Output = CoordOffset
type Output = CoordOffset
The resulting type after applying the
* operator.Source§impl Neg for CoordOffset
impl Neg for CoordOffset
Source§type Output = CoordOffset
type Output = CoordOffset
The resulting type after applying the
- operator.Source§fn neg(self) -> CoordOffset
fn neg(self) -> CoordOffset
Performs the unary
- operation. Read moreSource§impl Sub for CoordOffset
impl Sub for CoordOffset
Source§type Output = CoordOffset
type Output = CoordOffset
The resulting type after applying the
- operator.Source§fn sub(self, rhs: CoordOffset) -> CoordOffset
fn sub(self, rhs: CoordOffset) -> CoordOffset
Performs the
- operation. Read moreAuto Trait Implementations§
impl Freeze for CoordOffset
impl RefUnwindSafe for CoordOffset
impl Send for CoordOffset
impl Sync for CoordOffset
impl Unpin for CoordOffset
impl UnsafeUnpin for CoordOffset
impl UnwindSafe for CoordOffset
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