[][src]Struct makepad_geometry::Vector

pub struct Vector {
    pub x: f32,
    pub y: f32,
}

A vector in 2-dimensional Euclidian space.

A point represents a position, whereas a vector represents a displacement. That is, the result of subtracting two points is a vector. Moreover, the result of adding/subtracting a vector to/from a point is another point. However, adding two points is not defined. Similarly, whereas a point can be scaled, rotated, and translated, a vector can only be scaled and rotated.

Fields

x: f32y: f32

Methods

impl Vector[src]

pub fn new(x: f32, y: f32) -> Vector[src]

Creates a new vector with the given coordinates.

pub fn zero() -> Vector[src]

Returns the zero vector.

pub fn to_point(self) -> Point[src]

Converts self to a point.

This is equivalent to adding self to the origin.

pub fn length(self) -> f32[src]

Returns the length of self.

pub fn normalize(self) -> Option<Vector>[src]

Returns the unit vector in the direction of self, or None if self is the zero vector.

pub fn dot(self, other: Vector) -> f32[src]

Returns the dot product of self and other.

pub fn cross(self, other: Vector) -> f32[src]

Returns the cross product of self and other.

pub fn scale(self, v: Vector) -> Vector[src]

Non-uniformly scales self with the scale vector v.

Trait Implementations

impl Transform for Vector[src]

impl Clone for Vector[src]

impl Copy for Vector[src]

impl Default for Vector[src]

impl PartialEq<Vector> for Vector[src]

impl PartialOrd<Vector> for Vector[src]

impl Debug for Vector[src]

impl Div<f32> for Vector[src]

type Output = Vector

The resulting type after applying the / operator.

impl Sub<Vector> for Point[src]

type Output = Point

The resulting type after applying the - operator.

impl Sub<Vector> for Vector[src]

type Output = Vector

The resulting type after applying the - operator.

impl Add<Vector> for Point[src]

type Output = Point

The resulting type after applying the + operator.

impl Add<Vector> for Vector[src]

type Output = Vector

The resulting type after applying the + operator.

impl Mul<f32> for Vector[src]

type Output = Vector

The resulting type after applying the * operator.

impl Neg for Vector[src]

type Output = Vector

The resulting type after applying the - operator.

impl AddAssign<Vector> for Point[src]

impl AddAssign<Vector> for Vector[src]

impl SubAssign<Vector> for Point[src]

impl SubAssign<Vector> for Vector[src]

impl MulAssign<f32> for Vector[src]

impl DivAssign<f32> for Vector[src]

impl StructuralPartialEq for Vector[src]

Auto Trait Implementations

impl Send for Vector

impl Sync for Vector

impl Unpin for Vector

impl UnwindSafe for Vector

impl RefUnwindSafe for Vector

Blanket Implementations

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 = !

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.

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

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

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