pub trait PointOpsExt<F: Float>: PointLike<F> {
Show 23 methods
// Provided methods
fn splat(value: F) -> Self { ... }
fn add_f(self, scalar: F) -> Self { ... }
fn sub_f(self, scalar: F) -> Self { ... }
fn mul_f(self, scalar: F) -> Self { ... }
fn mul_add(self, a: Self, b: Self) -> Self { ... }
fn abs(self) -> Self { ... }
fn approx_eq(self, rhs: Self, epsilon: F) -> bool { ... }
fn approx_eq_f(self, scalar: F, epsilon: F) -> bool { ... }
fn round(self, n: usize) -> Self { ... }
fn max(self, other: Self) -> Self { ... }
fn min(self, other: Self) -> Self { ... }
fn cross(self, rhs: Self) -> F { ... }
fn dot(self, rhs: Self) -> F { ... }
fn length(self) -> F { ... }
fn length_squared(self) -> F { ... }
fn distance(self, rhs: Self) -> F { ... }
fn partial_cmp(&self, other: &F) -> Option<Ordering> { ... }
fn lt(&self, other: &F) -> bool { ... }
fn gt(self, other: &F) -> bool { ... }
fn le(self, other: &F) -> bool { ... }
fn ge(self, other: &F) -> bool { ... }
fn eq(self, other: &F) -> bool { ... }
fn ne(self, other: &F) -> bool { ... }
}Provided Methods§
Sourcefn splat(value: F) -> Self
fn splat(value: F) -> Self
Construct a new point using the same value for both components of self.
Sourcefn mul_add(self, a: Self, b: Self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.
Using mul_add can be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction.
Sourcefn approx_eq(self, rhs: Self, epsilon: F) -> bool
fn approx_eq(self, rhs: Self, epsilon: F) -> bool
Compare all components in self with rhs for approximate equality.
Sourcefn approx_eq_f(self, scalar: F, epsilon: F) -> bool
fn approx_eq_f(self, scalar: F, epsilon: F) -> bool
Compare all components in a point with a scalar for approximate equality.
Sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Returns a point-like containing the maximum values for each element of self and rhs.
In other words this computes [self.x().max(rhs.x), self.y().max(rhs.y())].
Sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Returns a point-like containing the minimum values for each element of self and rhs.
In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y)].
Sourcefn length_squared(self) -> F
fn length_squared(self) -> F
Computes the squared length of self.
This is generally faster than length as it avoids the square root.
Sourcefn distance(self, rhs: Self) -> F
fn distance(self, rhs: Self) -> F
Computes the Euclidean distance between two points in space.
This works by relocating one point to the origin, then computing the length of the resulting vector.
c = √((x₂ - x₁)² + (y₂ - y₁)²)fn partial_cmp(&self, other: &F) -> Option<Ordering>
fn lt(&self, other: &F) -> bool
fn gt(self, other: &F) -> bool
fn le(self, other: &F) -> bool
fn ge(self, other: &F) -> bool
fn eq(self, other: &F) -> bool
fn ne(self, other: &F) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.