[−][src]Struct makepad_geometry::Vector
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: f32
y: 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]
fn transform<T>(self, t: &T) -> Vector where
T: Transformation,
[src]
T: Transformation,
fn transform_mut<T>(&mut self, t: &T) where
T: Transformation,
[src]
T: Transformation,
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]
fn partial_cmp(&self, other: &Vector) -> Option<Ordering>
[src]
fn lt(&self, other: &Vector) -> bool
[src]
fn le(&self, other: &Vector) -> bool
[src]
fn gt(&self, other: &Vector) -> bool
[src]
fn ge(&self, other: &Vector) -> bool
[src]
impl Debug for Vector
[src]
impl Div<f32> for Vector
[src]
type Output = Vector
The resulting type after applying the /
operator.
fn div(self, k: f32) -> Vector
[src]
impl Sub<Vector> for Point
[src]
type Output = Point
The resulting type after applying the -
operator.
fn sub(self, v: Vector) -> Point
[src]
impl Sub<Vector> for Vector
[src]
type Output = Vector
The resulting type after applying the -
operator.
fn sub(self, other: Vector) -> Vector
[src]
impl Add<Vector> for Point
[src]
type Output = Point
The resulting type after applying the +
operator.
fn add(self, v: Vector) -> Point
[src]
impl Add<Vector> for Vector
[src]
type Output = Vector
The resulting type after applying the +
operator.
fn add(self, other: Vector) -> Vector
[src]
impl Mul<f32> for Vector
[src]
type Output = Vector
The resulting type after applying the *
operator.
fn mul(self, k: f32) -> Vector
[src]
impl Neg for Vector
[src]
impl AddAssign<Vector> for Point
[src]
fn add_assign(&mut self, vector: Vector)
[src]
impl AddAssign<Vector> for Vector
[src]
fn add_assign(&mut self, other: Vector)
[src]
impl SubAssign<Vector> for Point
[src]
fn sub_assign(&mut self, vector: Vector)
[src]
impl SubAssign<Vector> for Vector
[src]
fn sub_assign(&mut self, other: Vector)
[src]
impl MulAssign<f32> for Vector
[src]
fn mul_assign(&mut self, k: f32)
[src]
impl DivAssign<f32> for Vector
[src]
fn div_assign(&mut self, k: f32)
[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]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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 = !
The type returned in the event of a conversion error.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,