[−][src]Struct density_mesh_core::coord::Coord
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]
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.
fn add(self, other: Self) -> Self
[src]
impl Add<f32> for Coord
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Scalar) -> Self
[src]
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Div<Coord> for Coord
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: Self) -> Self
[src]
impl Div<f32> for Coord
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: Scalar) -> Self
[src]
impl Mul<Coord> for Coord
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self
[src]
impl Mul<f32> for Coord
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Scalar) -> Self
[src]
impl Neg for Coord
[src]
impl PartialEq<Coord> for Coord
[src]
impl Serialize for Coord
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Coord
[src]
impl Sub<Coord> for Coord
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self
[src]
impl Sub<f32> for Coord
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,