Struct radiant_rs::Vec2
[−]
[src]
pub struct Vec2<T: Debug + Float = f32>(pub T, pub T);
A 2-dimensional vector.
Methods
impl<T> Vec2<T> where T: Debug + Float
[src]
fn new() -> Self
Creates a new instances.
fn len(&self) -> T
Returns the length of the vector
fn dot(&self, other: &Self) -> T
Returns the dot-product of the vectors.
fn to_radians(&self) -> T
Returns the direction of the vector in radians.
fn to_degrees(&self) -> T
Returns the direction of the vector in degrees.
fn to_angle(&self) -> Angle<T>
Returns the direction of the vector as an angle instance.
fn from_radians(radians: T) -> Self
Creates a unit-vector from the angle given in radians.
fn from_degrees(degrees: T) -> Self
Creates a unit-vector from the angle given in degrees.
fn from_angle(angle: Angle<T>) -> Self
Creates a unit-vector from given angle.
fn normalize(self) -> Self
Normalizes the vector.
fn left(self) -> Self
The left pointing normal of the vector.
fn right(self) -> Self
The right pointing normal of the vector.
fn extend(self, extension_len: T) -> Self
Extends the vector by given length.
fn outbound(&self, bounding: Rect<T>) -> Option<Self>
Returns outbound vector for this point and given bounding box. Subtracting it from this point will result in a point on the bounding box.
fn is_zero(&self) -> bool
Returns true if the vecor is a zero-vector.
fn distance(&self, other: &Self) -> T
Returns distance to other point.
Trait Implementations
impl<T: Copy + Debug + Float> Copy for Vec2<T>
[src]
impl<T: Clone + Debug + Float> Clone for Vec2<T>
[src]
fn clone(&self) -> Vec2<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T> VecType<T> for Vec2<T> where T: Debug + Float
[src]
impl<T> From<(T, T)> for Vec2<T> where T: Debug + Float
[src]
impl<T> From<[T; 2]> for Vec2<T> where T: Debug + Float
[src]
impl<T> Neg for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the -
operator
fn neg(self) -> Vec2<T>
The method for the unary -
operator
impl<T> Add for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the +
operator
fn add(self, other: Vec2<T>) -> Vec2<T>
The method for the +
operator
impl<T> AddAssign for Vec2<T> where T: Debug + Float
[src]
fn add_assign(&mut self, other: Vec2<T>)
The method for the +=
operator
impl<T> Sub for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the -
operator
fn sub(self, other: Vec2<T>) -> Vec2<T>
The method for the -
operator
impl<T> SubAssign for Vec2<T> where T: Debug + Float
[src]
fn sub_assign(&mut self, other: Vec2<T>)
The method for the -=
operator
impl<T> Mul<Vec2<T>> for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the *
operator
fn mul(self, other: Vec2<T>) -> Vec2<T>
Multiplies individual vector components with those of the given vector.
impl<T> MulAssign<Vec2<T>> for Vec2<T> where T: Debug + Float
[src]
fn mul_assign(&mut self, other: Vec2<T>)
Mutates the vector by multiplying its components with those of the given vector.
impl<T> Mul<T> for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the *
operator
fn mul(self, other: T) -> Vec2<T>
Multiplies the vector with given scalar operand.
impl<T> MulAssign<T> for Vec2<T> where T: Debug + Float
[src]
fn mul_assign(&mut self, other: T)
Mutates the vector by multiplying it with the scalar operand.
impl<T> Div<Vec2<T>> for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the /
operator
fn div(self, other: Vec2<T>) -> Vec2<T>
Divides individual vector components with those of the given vector.
impl<T> DivAssign<Vec2<T>> for Vec2<T> where T: Debug + Float
[src]
fn div_assign(&mut self, other: Vec2<T>)
Mutates the vector by dividing its components with those of the given vector.
impl<T> Div<T> for Vec2<T> where T: Debug + Float
[src]
type Output = Vec2<T>
The resulting type after applying the /
operator
fn div(self, other: T) -> Vec2<T>
Divides the vector by given scalar operand.
impl<T> DivAssign<T> for Vec2<T> where T: Debug + Float
[src]
fn div_assign(&mut self, other: T)
Mutates the vector by dividing it by given scalar.