Struct nalgebra::Vector2
[−]
[src]
pub struct Vector2<N> { pub x: N, pub y: N, }
Vector of dimension 2.
The main differance between a point and a vector is that a vector is not affected by translations.
Fields
x: N
First component of the vector.
y: N
Second component of the vector.
Methods
impl<N> Vector2<N>
[src]
impl<N: Zero + One> Vector2<N>
[src]
fn x() -> Vector2<N>
Create a unit vector with its $compN
component equal to 1.0.
fn y() -> Vector2<N>
Create a unit vector with its $compN
component equal to 1.0.
impl<N: Copy> Vector2<N>
[src]
unsafe fn at_fast(&self, i: usize) -> N
Unsafe read access to a vector element by index.
unsafe fn set_fast(&mut self, i: usize, val: N)
Unsafe write access to a vector element by index.
impl<N> Vector2<N>
[src]
impl<N> Vector2<N>
[src]
fn to_point(self) -> Point2<N>
Converts this vector to a point.
fn as_point(&self) -> &Point2<N>
Reinterprets this vector as a point.
Trait Implementations
impl<N: Eq> Eq for Vector2<N>
[src]
impl<N: PartialEq> PartialEq for Vector2<N>
[src]
fn eq(&self, __arg_0: &Vector2<N>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Vector2<N>) -> bool
This method tests for !=
.
impl<N: Encodable> Encodable for Vector2<N>
[src]
impl<N: Decodable> Decodable for Vector2<N>
[src]
impl<N: Clone> Clone for Vector2<N>
[src]
fn clone(&self) -> Vector2<N>
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<N: Hash> Hash for Vector2<N>
[src]
fn hash<__HN: Hasher>(&self, __arg_0: &mut __HN)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<N: Debug> Debug for Vector2<N>
[src]
impl<N: Copy> Copy for Vector2<N>
[src]
impl<N: BaseFloat> PartialOrder for Vector2<N>
[src]
fn inf(&self, other: &Vector2<N>) -> Vector2<N>
Returns the infimum of this value and another
fn sup(&self, other: &Vector2<N>) -> Vector2<N>
Returns the supremum of this value and another
fn partial_cmp(&self, other: &Vector2<N>) -> PartialOrdering
Compare self
and other
using a partial ordering relation.
fn partial_lt(&self, other: &Vector2<N>) -> bool
Returns true
iff self
and other
are comparable and self < other
.
fn partial_le(&self, other: &Vector2<N>) -> bool
Returns true
iff self
and other
are comparable and self <= other
.
fn partial_gt(&self, other: &Vector2<N>) -> bool
Returns true
iff self
and other
are comparable and self > other
.
fn partial_ge(&self, other: &Vector2<N>) -> bool
Returns true
iff self
and other
are comparable and self >= other
.
fn partial_min<'a>(&'a self, other: &'a Self) -> Option<&'a Self>
Return the minimum of self
and other
if they are comparable.
fn partial_max<'a>(&'a self, other: &'a Self) -> Option<&'a Self>
Return the maximum of self
and other
if they are comparable.
fn partial_clamp<'a>(&'a self, min: &'a Self, max: &'a Self) -> Option<&'a Self>
Clamp value
between min
and max
. Returns None
if value
is not comparable to min
or max
. Read more
impl<Nin: Copy, Nout: Copy + Cast<Nin>> Cast<Vector2<Nin>> for Vector2<Nout>
[src]
impl<N> AsRef<[N; 2]> for Vector2<N>
[src]
impl<N> AsMut<[N; 2]> for Vector2<N>
[src]
impl<'a, N> From<&'a [N; 2]> for &'a Vector2<N>
[src]
impl<'a, N> From<&'a mut [N; 2]> for &'a mut Vector2<N>
[src]
impl<'a, N: Clone> From<&'a [N; 2]> for Vector2<N>
[src]
impl<N, T> Index<T> for Vector2<N> where [N]: Index<T>
[src]
type Output = [N]::Output
The returned type after indexing
fn index(&self, i: T) -> &[N]::Output
The method for the indexing (Foo[Bar]
) operation
impl<N, T> IndexMut<T> for Vector2<N> where [N]: IndexMut<T>
[src]
impl<N> Shape<usize> for Vector2<N>
[src]
impl<N: Copy> Indexable<usize, N> for Vector2<N>
[src]
fn swap(&mut self, i1: usize, i2: usize)
Swaps the i
-th element of self
with its j
-th element.
unsafe fn unsafe_at(&self, i: usize) -> N
Reads the i
-th element of self
. Read more
unsafe fn unsafe_set(&mut self, i: usize, val: N)
Writes to the i
-th element of self
. Read more
impl<N: Copy> Repeat<N> for Vector2<N>
[src]
fn repeat(val: N) -> Vector2<N>
Creates a new vector with all its components equal to a given value.
impl<N> Dimension for Vector2<N>
[src]
impl<N: Add<N, Output=N>> Add<Vector2<N>> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the +
operator
fn add(self, right: Vector2<N>) -> Vector2<N>
The method for the +
operator
impl<N: AddAssign<N>> AddAssign<Vector2<N>> for Vector2<N>
[src]
fn add_assign(&mut self, right: Vector2<N>)
The method for the +=
operator
impl<N: Sub<N, Output=N>> Sub<Vector2<N>> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the -
operator
fn sub(self, right: Vector2<N>) -> Vector2<N>
The method for the -
operator
impl<N: SubAssign<N>> SubAssign<Vector2<N>> for Vector2<N>
[src]
fn sub_assign(&mut self, right: Vector2<N>)
The method for the -=
operator
impl<N: Copy + Mul<N, Output=N>> Mul<Vector2<N>> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the *
operator
fn mul(self, right: Vector2<N>) -> Vector2<N>
The method for the *
operator
impl<N: MulAssign<N>> MulAssign<Vector2<N>> for Vector2<N>
[src]
fn mul_assign(&mut self, right: Vector2<N>)
The method for the *=
operator
impl<N: Copy + Div<N, Output=N>> Div<Vector2<N>> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the /
operator
fn div(self, right: Vector2<N>) -> Vector2<N>
The method for the /
operator
impl<N: DivAssign<N>> DivAssign<Vector2<N>> for Vector2<N>
[src]
fn div_assign(&mut self, right: Vector2<N>)
The method for the /=
operator
impl<N: Copy + Add<N, Output=N>> Add<N> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the +
operator
fn add(self, right: N) -> Vector2<N>
The method for the +
operator
impl<N: Copy + AddAssign<N>> AddAssign<N> for Vector2<N>
[src]
fn add_assign(&mut self, right: N)
The method for the +=
operator
impl<N: Copy + Sub<N, Output=N>> Sub<N> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the -
operator
fn sub(self, right: N) -> Vector2<N>
The method for the -
operator
impl<N: Copy + SubAssign<N>> SubAssign<N> for Vector2<N>
[src]
fn sub_assign(&mut self, right: N)
The method for the -=
operator
impl<N: Copy + Mul<N, Output=N>> Mul<N> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the *
operator
fn mul(self, right: N) -> Vector2<N>
The method for the *
operator
impl<N: Copy + MulAssign<N>> MulAssign<N> for Vector2<N>
[src]
fn mul_assign(&mut self, right: N)
The method for the *=
operator
impl<N: Copy + Div<N, Output=N>> Div<N> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the /
operator
fn div(self, right: N) -> Vector2<N>
The method for the /
operator
impl<N: Copy + DivAssign<N>> DivAssign<N> for Vector2<N>
[src]
fn div_assign(&mut self, right: N)
The method for the /=
operator
impl<N: Neg<Output=N> + Copy> Neg for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the -
operator
fn neg(self) -> Vector2<N>
The method for the unary -
operator
impl<N: BaseNum> Dot<N> for Vector2<N>
[src]
impl<N: Copy + Add<N, Output=N> + Neg<Output=N>> Translation<Vector2<N>> for Vector2<N>
[src]
fn translation(&self) -> Vector2<N>
Gets the translation associated with this object.
fn inverse_translation(&self) -> Vector2<N>
Gets the inverse translation associated with this object.
fn append_translation_mut(&mut self, t: &Vector2<N>)
Appends a translation to this object.
fn append_translation(&self, t: &Vector2<N>) -> Vector2<N>
Appends the translation amount
to a copy of t
.
fn prepend_translation_mut(&mut self, t: &Vector2<N>)
Prepends a translation to this object.
fn prepend_translation(&self, t: &Vector2<N>) -> Vector2<N>
Prepends the translation amount
to a copy of t
.
fn set_translation(&mut self, t: Vector2<N>)
Sets the translation.
impl<N: BaseFloat> Norm<N> for Vector2<N>
[src]
fn norm_squared(&self) -> N
Computes the squared norm of self
. Read more
fn normalize(&self) -> Vector2<N>
Gets the normalized version of a copy of v
.
fn normalize_mut(&mut self) -> N
Normalizes self
.
fn norm(&self) -> N
Computes the norm of self
.
impl<N: ApproxEq<N>> ApproxEq<N> for Vector2<N>
[src]
fn approx_epsilon(_: Option<Vector2<N>>) -> N
Default epsilon for approximation.
fn approx_ulps(_: Option<Vector2<N>>) -> u32
Default ULPs for approximation.
fn approx_eq(&self, other: &Vector2<N>) -> bool
Tests approximate equality.
fn approx_eq_eps(&self, other: &Vector2<N>, eps: &N) -> bool
Tests approximate equality using a custom epsilon.
fn approx_eq_ulps(&self, other: &Vector2<N>, ulps: u32) -> bool
Tests approximate equality using units in the last place (ULPs)
impl<N> One for Vector2<N> where N: Copy + One + Sub<N, Output=N> + Add<N, Output=N>
[src]
impl<N: Zero> Zero for Vector2<N>
[src]
fn zero() -> Vector2<N>
Returns the additive identity element of Self
, 0
. Read more
fn is_zero(&self) -> bool
Returns true
if self
is equal to the additive identity.
impl<N> FromIterator<N> for Vector2<N>
[src]
fn from_iter<I: IntoIterator<Item=N>>(iterator: I) -> Vector2<N>
Creates a value from an iterator. Read more
impl<N: Bounded> Bounded for Vector2<N>
[src]
impl<N: Axpy<N>> Axpy<N> for Vector2<N>
[src]
impl<N> Iterable<N> for Vector2<N>
[src]
impl<N> IterableMut<N> for Vector2<N>
[src]
impl<N: Copy + One + Zero> ToHomogeneous<Vector3<N>> for Vector2<N>
[src]
fn to_homogeneous(&self) -> Vector3<N>
Gets the homogeneous coordinates form of this object.
impl<N: Copy + Div<N, Output=N> + One + Zero> FromHomogeneous<Vector3<N>> for Vector2<N>
[src]
fn from(v: &Vector3<N>) -> Vector2<N>
Builds an object from its homogeneous coordinate form. Read more
impl<N: Copy + Add<N, Output=N> + Sub<N, Output=N>> Translate<Point2<N>> for Vector2<N>
[src]
fn translate(&self, other: &Point2<N>) -> Point2<N>
Apply a translation to an object.
fn inverse_translate(&self, other: &Point2<N>) -> Point2<N>
Apply an inverse translation to an object.
impl<N, O: Copy> Rotate<O> for Vector2<N>
[src]
fn rotate(&self, other: &O) -> O
Applies a rotation to v
.
fn inverse_rotate(&self, other: &O) -> O
Applies an inverse rotation to v
.
impl<N: Copy + Add<N, Output=N> + Sub<N, Output=N>> Transform<Point2<N>> for Vector2<N>
[src]
fn transform(&self, other: &Point2<N>) -> Point2<N>
Applies a transformation to v
.
fn inverse_transform(&self, other: &Point2<N>) -> Point2<N>
Applies an inverse transformation to v
.
impl<N> NumVector<N> for Vector2<N> where N: BaseNum
[src]
impl<N> FloatVector<N> for Vector2<N> where N: BaseFloat + ApproxEq<N>
[src]
impl<N: Absolute<N>> Absolute<Vector2<N>> for Vector2<N>
[src]
fn abs(m: &Vector2<N>) -> Vector2<N>
Computes some absolute value of this object. Typically, this will make all component of a matrix or vector positive. Read more
impl<N: Rand> Rand for Vector2<N>
[src]
fn rand<R: Rng>(rng: &mut R) -> Vector2<N>
Generates a random instance of this type using the specified source of randomness. Read more
impl<N: BaseFloat + Cast<f64>> Mean<N> for Vector2<N>
[src]
impl<N: Display> Display for Vector2<N>
[src]
impl<N: Copy + Mul<N, Output=N> + Zero> Outer for Vector2<N>
[src]
type OuterProductType = Matrix2<N>
Result type of the outer product.
fn outer(&self, other: &Vector2<N>) -> Matrix2<N>
Computes the outer product: a * b
impl<N: BaseNum> Mul<Rotation2<N>> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the *
operator
fn mul(self, right: Rotation2<N>) -> Vector2<N>
The method for the *
operator
impl<N: Copy + BaseNum> MulAssign<Rotation2<N>> for Vector2<N>
[src]
fn mul_assign(&mut self, right: Rotation2<N>)
The method for the *=
operator
impl<N: Copy + Mul<N, Output=N> + Add<N, Output=N>> Mul<Matrix2<N>> for Vector2<N>
[src]
type Output = Vector2<N>
The resulting type after applying the *
operator
fn mul(self, right: Matrix2<N>) -> Vector2<N>
The method for the *
operator
impl<N: Copy + Mul<N, Output=N> + Add<N, Output=N>> MulAssign<Matrix2<N>> for Vector2<N>
[src]
fn mul_assign(&mut self, right: Matrix2<N>)
The method for the *=
operator
impl<N: BaseFloat> RotationTo for Vector2<N>
[src]
type AngleType = N
Type of the angle between two elements.
type DeltaRotationType = Rotation2<N>
Type of the rotation between two elements.
fn angle_to(&self, other: &Self) -> N
Computes an angle nedded to transform the first element to the second one using a rotation. Read more
fn rotation_to(&self, other: &Self) -> Rotation2<N>
Computes the smallest rotation needed to transform the first element to the second one.
impl<N: Copy + Mul<N, Output=N> + Sub<N, Output=N>> Cross for Vector2<N>
[src]
type CrossProductType = Vector1<N>
The cross product output.
fn cross(&self, other: &Vector2<N>) -> Vector1<N>
Computes the cross product between two elements (usually vectors).
impl<N: Neg<Output=N> + Copy> CrossMatrix<Vector2<N>> for Vector2<N>
[src]
fn cross_matrix(&self) -> Vector2<N>
The matrix associated to any cross product with this vector. I.e. v.cross(anything)
= v.cross_matrix().rmul(anything)
. Read more
impl<N: Copy> Row<Vector1<N>> for Vector2<N>
[src]
fn nrows(&self) -> usize
The number of column of self
.
fn row(&self, i: usize) -> Vector1<N>
Reads the i
-th row of self
.
fn set_row(&mut self, i: usize, r: Vector1<N>)
Writes the i
-th row of self
.
impl<N: Copy + One + Zero + Neg<Output=N>> Basis for Vector2<N>
[src]
fn canonical_basis<F: FnMut(Vector2<N>) -> bool>(f: F)
Iterates through the canonical basis of the space in which this object lives.
fn orthonormal_subspace_basis<F: FnMut(Vector2<N>) -> bool>(n: &Vector2<N>, f: F)
Iterates through a basis of the subspace orthogonal to self
.
fn canonical_basis_element(i: usize) -> Option<Vector2<N>>
Gets the ith element of the canonical basis.