#[repr(C)]pub struct Vector2<S> {
pub x: S,
pub y: S,
}Expand description
A 2-dimensional vector.
This type is marked as #[repr(C)].
Fields§
§x: SThe x component of the vector.
y: SThe y component of the vector.
Implementations§
Source§impl<S> Vector2<S>
impl<S> Vector2<S>
Trait Implementations§
Source§impl<S> AbsDiffEq for Vector2<S>where
S: BaseFloat,
impl<S> AbsDiffEq for Vector2<S>where
S: BaseFloat,
Source§fn default_epsilon() -> <S as AbsDiffEq>::Epsilon
fn default_epsilon() -> <S as AbsDiffEq>::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(
&self,
other: &Vector2<S>,
epsilon: <S as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &Vector2<S>, epsilon: <S as AbsDiffEq>::Epsilon, ) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq.Source§impl<S> AddAssign<Vector2<S>> for Point2<S>
impl<S> AddAssign<Vector2<S>> for Point2<S>
Source§fn add_assign(&mut self, vector: Vector2<S>)
fn add_assign(&mut self, vector: Vector2<S>)
Performs the
+= operation. Read moreSource§impl<S> AddAssign for Vector2<S>
impl<S> AddAssign for Vector2<S>
Source§fn add_assign(&mut self, other: Vector2<S>)
fn add_assign(&mut self, other: Vector2<S>)
Performs the
+= operation. Read moreSource§impl<S> Array for Vector2<S>where
S: Copy,
impl<S> Array for Vector2<S>where
S: Copy,
type Element = S
Source§fn from_value(scalar: S) -> Vector2<S>
fn from_value(scalar: S) -> Vector2<S>
Construct a vector from a single value, replicating it. Read more
Source§fn as_mut_ptr(&mut self) -> *mut Self::Element
fn as_mut_ptr(&mut self) -> *mut Self::Element
Get a mutable pointer to the first element of the array.
Source§fn swap_elements(&mut self, i: usize, j: usize)
fn swap_elements(&mut self, i: usize, j: usize)
Swap the elements at indices
i and j in-place.Source§impl<S> ControlPoint<S> for Vector2<S>where
S: BaseFloat,
impl<S> ControlPoint<S> for Vector2<S>where
S: BaseFloat,
Source§impl<'de, S> Deserialize<'de> for Vector2<S>where
S: Deserialize<'de>,
impl<'de, S> Deserialize<'de> for Vector2<S>where
S: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vector2<S>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vector2<S>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<S> DivAssign<S> for Vector2<S>
impl<S> DivAssign<S> for Vector2<S>
Source§fn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the
/= operation. Read moreSource§impl<S> ElementWise<S> for Vector2<S>where
S: BaseNum,
impl<S> ElementWise<S> for Vector2<S>where
S: BaseNum,
fn add_element_wise(self, rhs: S) -> Vector2<S>
fn sub_element_wise(self, rhs: S) -> Vector2<S>
fn mul_element_wise(self, rhs: S) -> Vector2<S>
fn div_element_wise(self, rhs: S) -> Vector2<S>
fn rem_element_wise(self, rhs: S) -> Vector2<S>
fn add_assign_element_wise(&mut self, rhs: S)
fn sub_assign_element_wise(&mut self, rhs: S)
fn mul_assign_element_wise(&mut self, rhs: S)
fn div_assign_element_wise(&mut self, rhs: S)
fn rem_assign_element_wise(&mut self, rhs: S)
Source§impl<S> ElementWise for Vector2<S>where
S: BaseNum,
impl<S> ElementWise for Vector2<S>where
S: BaseNum,
fn add_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn sub_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn mul_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn div_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn rem_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn add_assign_element_wise(&mut self, rhs: Vector2<S>)
fn sub_assign_element_wise(&mut self, rhs: Vector2<S>)
fn mul_assign_element_wise(&mut self, rhs: Vector2<S>)
fn div_assign_element_wise(&mut self, rhs: Vector2<S>)
fn rem_assign_element_wise(&mut self, rhs: Vector2<S>)
Source§impl<S> Homogeneous<S> for Vector2<S>where
S: BaseFloat,
impl<S> Homogeneous<S> for Vector2<S>where
S: BaseFloat,
Source§fn from_point(point: <Vector2<S> as Homogeneous<S>>::Point) -> Vector2<S>
fn from_point(point: <Vector2<S> as Homogeneous<S>>::Point) -> Vector2<S>
Returns homogeneous coordinate.
Source§fn from_point_weight(point: Self::Point, weight: S) -> Self
fn from_point_weight(point: Self::Point, weight: S) -> Self
Returns homogeneous coordinate from point and weight.
Source§fn to_point(self) -> Self::Point
fn to_point(self) -> Self::Point
Returns the projection to the plane whose the last component is
1.0.Source§fn rat_der(self, der: Self) -> <Self::Point as EuclideanSpace>::Diff
fn rat_der(self, der: Self) -> <Self::Point as EuclideanSpace>::Diff
Returns the derivation of the rational curve. Read more
Source§fn rat_der2(
self,
der: Self,
der2: Self,
) -> <Self::Point as EuclideanSpace>::Diff
fn rat_der2( self, der: Self, der2: Self, ) -> <Self::Point as EuclideanSpace>::Diff
Returns the 2nd-ord derivation of the rational curve. Read more
Source§fn rat_cross_der(
&self,
uder: Self,
vder: Self,
uvder: Self,
) -> <Self::Point as EuclideanSpace>::Diff
fn rat_cross_der( &self, uder: Self, vder: Self, uvder: Self, ) -> <Self::Point as EuclideanSpace>::Diff
Returns the cross derivation of the rational surface. Read more
Source§impl<S> InnerSpace for Vector2<S>where
S: BaseNum,
impl<S> InnerSpace for Vector2<S>where
S: BaseNum,
Source§fn angle(self, other: Vector2<S>) -> Rad<S>where
S: BaseFloat,
fn angle(self, other: Vector2<S>) -> Rad<S>where
S: BaseFloat,
Returns the angle between two vectors in radians.
Source§fn is_perpendicular(self, other: Self) -> bool
fn is_perpendicular(self, other: Self) -> bool
Returns
true if the vector is perpendicular (at right angles) to the
other vector.Source§fn magnitude2(self) -> Self::Scalar
fn magnitude2(self) -> Self::Scalar
Returns the squared magnitude. Read more
Source§fn project_on(self, other: Self) -> Self
fn project_on(self, other: Self) -> Self
Returns the
vector projection
of the current inner space projected onto the supplied argument.
Source§impl<S> MetricSpace for Vector2<S>where
S: BaseNum,
impl<S> MetricSpace for Vector2<S>where
S: BaseNum,
Source§impl<S> MulAssign<S> for Vector2<S>
impl<S> MulAssign<S> for Vector2<S>
Source§fn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the
*= operation. Read moreSource§impl<S> RelativeEq for Vector2<S>where
S: BaseFloat,
impl<S> RelativeEq for Vector2<S>where
S: BaseFloat,
Source§fn default_max_relative() -> <S as AbsDiffEq>::Epsilon
fn default_max_relative() -> <S as AbsDiffEq>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Vector2<S>,
epsilon: <S as AbsDiffEq>::Epsilon,
max_relative: <S as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &Vector2<S>, epsilon: <S as AbsDiffEq>::Epsilon, max_relative: <S as AbsDiffEq>::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
The inverse of
RelativeEq::relative_eq.Source§impl<S> RemAssign<S> for Vector2<S>
impl<S> RemAssign<S> for Vector2<S>
Source§fn rem_assign(&mut self, scalar: S)
fn rem_assign(&mut self, scalar: S)
Performs the
%= operation. Read moreSource§impl<S> Serialize for Vector2<S>where
S: Serialize,
impl<S> Serialize for Vector2<S>where
S: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl<S> SubAssign<Vector2<S>> for Point2<S>
impl<S> SubAssign<Vector2<S>> for Point2<S>
Source§fn sub_assign(&mut self, vector: Vector2<S>)
fn sub_assign(&mut self, vector: Vector2<S>)
Performs the
-= operation. Read moreSource§impl<S> SubAssign for Vector2<S>
impl<S> SubAssign for Vector2<S>
Source§fn sub_assign(&mut self, other: Vector2<S>)
fn sub_assign(&mut self, other: Vector2<S>)
Performs the
-= operation. Read moreSource§impl<S> TangentSpace<S> for Vector2<S>where
S: BaseFloat,
impl<S> TangentSpace<S> for Vector2<S>where
S: BaseFloat,
Source§impl<S> UlpsEq for Vector2<S>where
S: BaseFloat,
impl<S> UlpsEq for Vector2<S>where
S: BaseFloat,
Source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
Source§impl<S> VectorSpace for Vector2<S>where
S: BaseNum,
impl<S> VectorSpace for Vector2<S>where
S: BaseNum,
impl<S> Copy for Vector2<S>where
S: Copy,
impl<S> Eq for Vector2<S>where
S: Eq,
impl<S> StructuralPartialEq for Vector2<S>
Auto Trait Implementations§
impl<S> Freeze for Vector2<S>where
S: Freeze,
impl<S> RefUnwindSafe for Vector2<S>where
S: RefUnwindSafe,
impl<S> Send for Vector2<S>where
S: Send,
impl<S> Sync for Vector2<S>where
S: Sync,
impl<S> Unpin for Vector2<S>where
S: Unpin,
impl<S> UnwindSafe for Vector2<S>where
S: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more