PointTrait

Trait PointTrait 

Source
pub trait PointTrait: Clone + PartialEq{
    type PScalar;

    const DIMENSION: u8;

    // Required methods
    fn x(&self) -> Self::PScalar;
    fn y(&self) -> Self::PScalar;
    fn set_x(&mut self, x: Self::PScalar);
    fn set_y(&mut self, y: Self::PScalar);
    fn at(&self, index: u8) -> Self::PScalar;
    fn at_mut(&mut self, index: u8) -> &mut Self::PScalar;

    // Provided method
    fn dist_sq<Q: PointTrait<PScalar = Self::PScalar>>(
        a: &Self,
        b: &Q,
    ) -> Self::PScalar { ... }
}

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn x(&self) -> Self::PScalar

Source

fn y(&self) -> Self::PScalar

Source

fn set_x(&mut self, x: Self::PScalar)

Source

fn set_y(&mut self, y: Self::PScalar)

Source

fn at(&self, index: u8) -> Self::PScalar

Source

fn at_mut(&mut self, index: u8) -> &mut Self::PScalar

Provided Methods§

Source

fn dist_sq<Q: PointTrait<PScalar = Self::PScalar>>( a: &Self, b: &Q, ) -> Self::PScalar

Returns the squared distance between this point and another point that is using the same scalar type.

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.

Implementations on Foreign Types§

Source§

impl PointTrait for Vector2<f32>

Available on crate features cgmath and vector-traits only.
Source§

const DIMENSION: u8 = 2u8

Source§

type PScalar = f32

Source§

fn x(&self) -> Self::PScalar

Source§

fn y(&self) -> Self::PScalar

Source§

fn set_x(&mut self, x: Self::PScalar)

Source§

fn set_y(&mut self, y: Self::PScalar)

Source§

fn at(&self, index: u8) -> Self::PScalar

Source§

fn at_mut(&mut self, index: u8) -> &mut Self::PScalar

Source§

impl PointTrait for Vector2<f64>

Available on crate features cgmath and vector-traits only.
Source§

const DIMENSION: u8 = 2u8

Source§

type PScalar = f64

Source§

fn x(&self) -> Self::PScalar

Source§

fn y(&self) -> Self::PScalar

Source§

fn set_x(&mut self, x: Self::PScalar)

Source§

fn set_y(&mut self, y: Self::PScalar)

Source§

fn at(&self, index: u8) -> Self::PScalar

Source§

fn at_mut(&mut self, index: u8) -> &mut Self::PScalar

Source§

impl PointTrait for Vec2

Available on crate features glam and vector-traits only.
Source§

const DIMENSION: u8 = 2u8

Source§

type PScalar = f32

Source§

fn x(&self) -> Self::PScalar

Source§

fn y(&self) -> Self::PScalar

Source§

fn set_x(&mut self, x: Self::PScalar)

Source§

fn set_y(&mut self, y: Self::PScalar)

Source§

fn at(&self, index: u8) -> Self::PScalar

Source§

fn at_mut(&mut self, index: u8) -> &mut Self::PScalar

Source§

impl PointTrait for DVec2

Available on crate features glam and vector-traits only.
Source§

const DIMENSION: u8 = 2u8

Source§

type PScalar = f64

Source§

fn x(&self) -> Self::PScalar

Source§

fn y(&self) -> Self::PScalar

Source§

fn set_x(&mut self, x: Self::PScalar)

Source§

fn set_y(&mut self, y: Self::PScalar)

Source§

fn at(&self, index: u8) -> Self::PScalar

Source§

fn at_mut(&mut self, index: u8) -> &mut Self::PScalar

Source§

impl PointTrait for Vec2A

Available on crate features glam and vector-traits only.
Source§

const DIMENSION: u8 = 2u8

Source§

type PScalar = f32

Source§

fn x(&self) -> Self::PScalar

Source§

fn y(&self) -> Self::PScalar

Source§

fn set_x(&mut self, x: Self::PScalar)

Source§

fn set_y(&mut self, y: Self::PScalar)

Source§

fn at(&self, index: u8) -> Self::PScalar

Source§

fn at_mut(&mut self, index: u8) -> &mut Self::PScalar

Implementors§