Struct quicksilver::geom::Vector [−][src]
A 2D vector with an arbitrary numeric type
Fields
x: f32
The x coordinate of the vector
y: f32
The y coordinate of the vector
Methods
impl Vector
[src]
impl Vector
pub fn zero() -> Vector
[src]
pub fn zero() -> Vector
The zero vector
pub fn x() -> Vector
[src]
pub fn x() -> Vector
A vector with x = 1f32, y = 0f32
pub fn y() -> Vector
[src]
pub fn y() -> Vector
A vector with x = 0f32, y = 1f32
pub fn one() -> Vector
[src]
pub fn one() -> Vector
A vector with x = 1f32, y = 1f32
pub fn new<T: Scalar>(x: T, y: T) -> Vector
[src]
pub fn new<T: Scalar>(x: T, y: T) -> Vector
Create a new vector
pub fn into_vector(self) -> Vector2<f32>
[src]
pub fn into_vector(self) -> Vector2<f32>
Convert this vector into an nalgebra Vector2
pub fn into_point(self) -> Point2<f32>
[src]
pub fn into_point(self) -> Point2<f32>
Convert this vector into an nalgebra Point2
pub fn from_angle<T: Scalar>(angle: T) -> Vector
[src]
pub fn from_angle<T: Scalar>(angle: T) -> Vector
Create a unit vector at a given angle
pub fn len2(self) -> f32
[src]
pub fn len2(self) -> f32
Get the squared length of the vector (faster than getting the length)
pub fn len(self) -> f32
[src]
pub fn len(self) -> f32
Get the length of the vector
pub fn clamp(self, min_bound: Vector, max_bound: Vector) -> Vector
[src]
pub fn clamp(self, min_bound: Vector, max_bound: Vector) -> Vector
Clamp a vector somewhere between a minimum and a maximum
pub fn cross(self, other: Vector) -> f32
[src]
pub fn cross(self, other: Vector) -> f32
Get the cross product of a vector
pub fn dot(self, other: Vector) -> f32
[src]
pub fn dot(self, other: Vector) -> f32
Get the dot product of a vector
pub fn normalize(self) -> Vector
[src]
pub fn normalize(self) -> Vector
Normalize the vector's length from [0, 1]
pub fn x_comp(self) -> Vector
[src]
pub fn x_comp(self) -> Vector
Get only the X component of the Vector, represented as a vector
pub fn y_comp(self) -> Vector
[src]
pub fn y_comp(self) -> Vector
Get only the Y component of the Vector, represented as a vector
pub fn recip(self) -> Vector
[src]
pub fn recip(self) -> Vector
Get the vector equal to Vector(1 / x, 1 / y)
pub fn times(self, other: Vector) -> Vector
[src]
pub fn times(self, other: Vector) -> Vector
Multiply the components in the matching places
pub fn angle(self) -> f32
[src]
pub fn angle(self) -> f32
Get the angle a vector forms with the positive x-axis, counter clockwise
pub fn with_len(self, length: f32) -> Vector
[src]
pub fn with_len(self, length: f32) -> Vector
Create a vector with the same angle and the given length
Trait Implementations
impl Copy for Vector
[src]
impl Copy for Vector
impl Clone for Vector
[src]
impl Clone for Vector
fn clone(&self) -> Vector
[src]
fn clone(&self) -> Vector
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Default for Vector
[src]
impl Default for Vector
impl Debug for Vector
[src]
impl Debug for Vector
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Neg for Vector
[src]
impl Neg for Vector
type Output = Vector
The resulting type after applying the -
operator.
fn neg(self) -> Vector
[src]
fn neg(self) -> Vector
Performs the unary -
operation.
impl Add for Vector
[src]
impl Add for Vector
type Output = Vector
The resulting type after applying the +
operator.
fn add(self, rhs: Vector) -> Vector
[src]
fn add(self, rhs: Vector) -> Vector
Performs the +
operation.
impl AddAssign for Vector
[src]
impl AddAssign for Vector
fn add_assign(&mut self, rhs: Vector)
[src]
fn add_assign(&mut self, rhs: Vector)
Performs the +=
operation.
impl Sub for Vector
[src]
impl Sub for Vector
type Output = Vector
The resulting type after applying the -
operator.
fn sub(self, rhs: Vector) -> Vector
[src]
fn sub(self, rhs: Vector) -> Vector
Performs the -
operation.
impl SubAssign for Vector
[src]
impl SubAssign for Vector
fn sub_assign(&mut self, rhs: Vector)
[src]
fn sub_assign(&mut self, rhs: Vector)
Performs the -=
operation.
impl<T: Scalar> Div<T> for Vector
[src]
impl<T: Scalar> Div<T> for Vector
type Output = Vector
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Vector
[src]
fn div(self, rhs: T) -> Vector
Performs the /
operation.
impl<T: Scalar> DivAssign<T> for Vector
[src]
impl<T: Scalar> DivAssign<T> for Vector
fn div_assign(&mut self, rhs: T)
[src]
fn div_assign(&mut self, rhs: T)
Performs the /=
operation.
impl<T: Scalar> Mul<T> for Vector
[src]
impl<T: Scalar> Mul<T> for Vector
type Output = Vector
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Vector
[src]
fn mul(self, rhs: T) -> Vector
Performs the *
operation.
impl<T: Scalar> MulAssign<T> for Vector
[src]
impl<T: Scalar> MulAssign<T> for Vector
fn mul_assign(&mut self, rhs: T)
[src]
fn mul_assign(&mut self, rhs: T)
Performs the *=
operation.
impl PartialEq for Vector
[src]
impl PartialEq for Vector
fn eq(&self, other: &Vector) -> bool
[src]
fn eq(&self, other: &Vector) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for Vector
[src]
impl Eq for Vector
impl Display for Vector
[src]
impl Display for Vector
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Distribution<Vector> for Standard
[src]
impl Distribution<Vector> for Standard
fn sample<R: Rng + ?Sized>(&self, rand: &mut R) -> Vector
[src]
fn sample<R: Rng + ?Sized>(&self, rand: &mut R) -> Vector
Generate a random value of T
, using rng
as the source of randomness.
ⓘImportant traits for DistIter<'a, D, R, T>fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
[src]
fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as the source of randomness. Read more
impl Positioned for Vector
[src]
impl Positioned for Vector
fn center(&self) -> Vector
[src]
fn center(&self) -> Vector
Its center as a vector
fn bounding_box(&self) -> Rectangle
[src]
fn bounding_box(&self) -> Rectangle
The smallest possible rectangle that fully contains the shape
impl From<Vector2<f32>> for Vector
[src]
impl From<Vector2<f32>> for Vector
impl From<Point2<f32>> for Vector
[src]
impl From<Point2<f32>> for Vector
impl Mul<Vector> for Transform
[src]
impl Mul<Vector> for Transform
Transform a vector