Trait Is3D

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

    // Provided methods
    fn xyz(&self) -> [f64; 3] { ... }
    fn xy(&self) -> [f64; 2] { ... }
    fn xz(&self) -> [f64; 2] { ... }
    fn yz(&self) -> [f64; 2] { ... }
    fn dot(&self, other: &dyn Is3D) -> f64 { ... }
    fn abs(&self) -> NonNegative { ... }
    fn rad_to(&self, other: &dyn Is3D) -> Result<Rad> { ... }
    fn to_str(&self) -> String { ... }
}
Expand description

Is3D is a trait used for types which are positioned within the 3D space

Required Methods§

Source

fn x(&self) -> f64

Should return the x-coordinate

Source

fn y(&self) -> f64

Should return the y-coordinate

Source

fn z(&self) -> f64

Should return the z-coordinate

Provided Methods§

Source

fn xyz(&self) -> [f64; 3]

Returns the position as x,y,z array

Source

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

Returns the components of the position as array

Source

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

Returns the components of the position as array

Source

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

Returns the components of the position as array

Source

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

Calculates the dot product with another Is3D

Source

fn abs(&self) -> NonNegative

The absolute / length of this position

Source

fn rad_to(&self, other: &dyn Is3D) -> Result<Rad>

Calculates the angle to the other Is3D in radians

Source

fn to_str(&self) -> String

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

Trait Implementations§

Source§

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

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> Is3D for Box<P>
where P: IsND + Is3D,

Source§

fn x(&self) -> f64

Source§

fn y(&self) -> f64

Source§

fn z(&self) -> f64

Implementors§