[][src]Struct density_mesh_core::coord::Coord

pub struct Coord {
    pub x: Scalar,
    pub y: Scalar,
}

Point coordinate.

Examples

use density_mesh_core::prelude::*;

let a = Coord::new(0.0, 0.0);
let b = Coord::new(2.0, 0.0);
assert_eq!((b - a).magnitude(), 2.0);
assert_eq!((b - a).sqr_magnitude(), 4.0);
assert_eq!((b - a).normalized(), Coord::new(1.0, 0.0));
assert_eq!((b - a).normalized().right(), Coord::new(0.0, -1.0));
assert_eq!(Coord::new(1.0, 0.0).dot(Coord::new(-1.0, 0.0)), -1.0);

Fields

x: Scalar

X value.

y: Scalar

Y value.

Implementations

impl Coord[src]

pub fn new(x: Scalar, y: Scalar) -> Self[src]

Create new point coordinate.

Arguments

  • x - X value.
  • y - Y value.

pub fn sqr_magnitude(self) -> Scalar[src]

Return squared length of the vector.

pub fn magnitude(self) -> Scalar[src]

Return length of the vector.

pub fn normalized(self) -> Self[src]

Return normalized vector (length equals to 1).

pub fn dot(self, other: Self) -> Scalar[src]

Returns dot product (cosinus of the angle between two vectors when both are normalized).

       self 1 other
            ^
            |
other 0 <---*---> 0 other
            |
            v
           -1
          other

Arguments

  • other - Other vector.

pub fn right(self) -> Self[src]

Return right vector.

     ^
self |
     *---> right

Trait Implementations

impl Add<Coord> for Coord[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<f32> for Coord[src]

type Output = Self

The resulting type after applying the + operator.

impl Clone for Coord[src]

impl Copy for Coord[src]

impl Debug for Coord[src]

impl Default for Coord[src]

impl<'de> Deserialize<'de> for Coord[src]

impl Div<Coord> for Coord[src]

type Output = Self

The resulting type after applying the / operator.

impl Div<f32> for Coord[src]

type Output = Self

The resulting type after applying the / operator.

impl Mul<Coord> for Coord[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<f32> for Coord[src]

type Output = Self

The resulting type after applying the * operator.

impl Neg for Coord[src]

type Output = Self

The resulting type after applying the - operator.

impl PartialEq<Coord> for Coord[src]

impl Serialize for Coord[src]

impl StructuralPartialEq for Coord[src]

impl Sub<Coord> for Coord[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<f32> for Coord[src]

type Output = Self

The resulting type after applying the - operator.

Auto Trait Implementations

impl RefUnwindSafe for Coord

impl Send for Coord

impl Sync for Coord

impl Unpin for Coord

impl UnwindSafe for Coord

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.