Trait Is2D

Source
pub trait Is2D: IsND {
    // Required methods
    fn x(&self) -> f64;
    fn y(&self) -> f64;

    // Provided methods
    fn xy(&self) -> [f64; 2] { ... }
    fn dot(&self, other: &dyn Is2D) -> f64 { ... }
    fn cross(&self, other: &dyn Is2D) -> f64 { ... }
    fn abs(&self) -> NonNegative { ... }
    fn rad_to(&self, other: &dyn Is2D) -> Rad { ... }
    fn to_str(&self) -> String { ... }
}
Expand description

Is2D is a trait used for types which are positioned within the 2D space

Required Methods§

Source

fn x(&self) -> f64

Should return the x-coordinate

Source

fn y(&self) -> f64

Should return the y-coordinate

Provided Methods§

Source

fn xy(&self) -> [f64; 2]

Returns the Position as x,y array

Source

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

Calculates the dot product with another Is2D

Source

fn cross(&self, other: &dyn Is2D) -> f64

Calculates the cross product with another Is2D

Source

fn abs(&self) -> NonNegative

The absolute / length of this position

Source

fn rad_to(&self, other: &dyn Is2D) -> Rad

Calculates the angle to the other Is2D in radians

Source

fn to_str(&self) -> String

Transforms the position in a “x y” string. E.g. “3.72 5.99”

Trait Implementations§

Source§

impl<P> HasDistanceTo<P> for dyn Is2D
where P: Is2D,

Source§

fn sqr_distance(&self, other: &P) -> NonNegative

Should return the sqr distance to other
Source§

fn distance(&self, other: &T) -> NonNegative

The distance to other

Implementations on Foreign Types§

Source§

impl<P> Is2D for Box<P>
where P: IsND + Is2D,

Source§

fn x(&self) -> f64

Source§

fn y(&self) -> f64

Implementors§