Trait Points2

Source
pub trait Points2 {
    type Output;

Show 16 methods // Required methods fn x(&self) -> f64; fn y(&self) -> f64; fn with_x(&self, x: f64) -> Self::Output; fn with_y(&self, y: f64) -> Self::Output; fn to_polar(&self) -> PolarPoint; fn magnitude(&self) -> f64; fn magnitude_squared(&self) -> f64; fn distance_from_origin(&self) -> f64; fn distance_from_point(&self, other: &Self) -> f64; fn dot(&self, other: &Self) -> f64; fn rotate(&self, alpha: &f64) -> Self::Output; fn unit(&self) -> Self::Output; fn zero() -> Self::Output; fn identity() -> Self::Output; fn i_hat() -> Self::Output; fn j_hat() -> Self::Output;
}
Expand description

§Points Traits

Overloading of +-*/, as well as helper functions Traits specific to Points2

Required Associated Types§

Source

type Output

Set output to be Points2

Required Methods§

Source

fn x(&self) -> f64

Returns x

Source

fn y(&self) -> f64

Returns y

Source

fn with_x(&self, x: f64) -> Self::Output

Returns Point with original y, but new x

Source

fn with_y(&self, y: f64) -> Self::Output

Returns Point with original y, but new x

Source

fn to_polar(&self) -> PolarPoint

Converts Point2 to PolarPoint

Source

fn magnitude(&self) -> f64

Returns magnitude of vector

Source

fn magnitude_squared(&self) -> f64

Returns squared magnitude of vector

Source

fn distance_from_origin(&self) -> f64

Returns distance from point to origin

Source

fn distance_from_point(&self, other: &Self) -> f64

Returns distance from one point to another

Source

fn dot(&self, other: &Self) -> f64

Returns dot product of two vectors

Source

fn rotate(&self, alpha: &f64) -> Self::Output

Rotates point anti-clockwise about an angle alpha

Source

fn unit(&self) -> Self::Output

Returns normalised vector from input vector

Source

fn zero() -> Self::Output

Returns a point/vector of zeros

Source

fn identity() -> Self::Output

Returns a point/vector of ones

Source

fn i_hat() -> Self::Output

Returns a point/vector with x = 1.0, y = 0.0

Source

fn j_hat() -> Self::Output

Returns a point/vector with x = 0.0, y = 1.0

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.

Implementors§