pub struct Vector2 {
pub x: f32,
pub y: f32,
}Expand description
A vector with two single-precision components.
Fields§
§x: f32The X component of the vector.
y: f32The Y component of the vector.
Implementations§
Source§impl Vector2
impl Vector2
Sourcepub const fn from_value(value: f32) -> Self
pub const fn from_value(value: f32) -> Self
Creates a vector whose components all have the same value.
Sourcepub fn abs(value: Vector2) -> Vector2
pub fn abs(value: Vector2) -> Vector2
Returns a vector whose elements are the absolute values of each of the specified vector’s elements.
Sourcepub fn clamp(value1: Vector2, min: Vector2, max: Vector2) -> Vector2
pub fn clamp(value1: Vector2, min: Vector2, max: Vector2) -> Vector2
Restricts a vector between a minimum and a maximum value
(min(max(value, min), max), so max wins when the bounds are inverted).
Sourcepub fn distance(value1: Vector2, value2: Vector2) -> f32
pub fn distance(value1: Vector2, value2: Vector2) -> f32
Computes the Euclidean distance between the two given points.
Sourcepub fn distance_squared(value1: Vector2, value2: Vector2) -> f32
pub fn distance_squared(value1: Vector2, value2: Vector2) -> f32
Returns the Euclidean distance squared between two specified points.
Sourcepub fn length_squared(&self) -> f32
pub fn length_squared(&self) -> f32
Returns the length of the vector squared.
Sourcepub fn lerp(value1: Vector2, value2: Vector2, amount: f32) -> Vector2
pub fn lerp(value1: Vector2, value2: Vector2, amount: f32) -> Vector2
Performs a linear interpolation between two vectors based on the given weighting.
Sourcepub fn max(value1: Vector2, value2: Vector2) -> Vector2
pub fn max(value1: Vector2, value2: Vector2) -> Vector2
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
Sourcepub fn min(value1: Vector2, value2: Vector2) -> Vector2
pub fn min(value1: Vector2, value2: Vector2) -> Vector2
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
Sourcepub fn normalize(value: Vector2) -> Vector2
pub fn normalize(value: Vector2) -> Vector2
Returns a vector with the same direction as the specified vector, but with a length of one (NaN components for a zero-length vector).
Sourcepub fn square_root(value: Vector2) -> Vector2
pub fn square_root(value: Vector2) -> Vector2
Returns a vector whose elements are the square root of each of a specified vector’s elements.
Sourcepub fn transform(position: Vector2, matrix: Matrix3x2) -> Vector2
pub fn transform(position: Vector2, matrix: Matrix3x2) -> Vector2
Transforms a vector by a specified 3x2 matrix.
Sourcepub fn transform_matrix4x4(position: Vector2, matrix: Matrix4x4) -> Vector2
pub fn transform_matrix4x4(position: Vector2, matrix: Matrix4x4) -> Vector2
Transforms a vector by a specified 4x4 matrix.
Sourcepub fn transform_quaternion(value: Vector2, rotation: Quaternion) -> Vector2
pub fn transform_quaternion(value: Vector2, rotation: Quaternion) -> Vector2
Transforms a vector by the specified rotation.
Sourcepub fn transform_normal(normal: Vector2, matrix: Matrix3x2) -> Vector2
pub fn transform_normal(normal: Vector2, matrix: Matrix3x2) -> Vector2
Transforms a vector normal by the given 3x2 matrix.
Trait Implementations§
Source§impl AddAssign for Vector2
impl AddAssign for Vector2
Source§fn add_assign(&mut self, right: Vector2)
fn add_assign(&mut self, right: Vector2)
+= operation. Read moreSource§impl BatchValue for Vector2
impl BatchValue for Vector2
impl Copy for Vector2
Source§impl DivAssign for Vector2
impl DivAssign for Vector2
Source§fn div_assign(&mut self, right: Vector2)
fn div_assign(&mut self, right: Vector2)
/= operation. Read moreSource§impl DivAssign<f32> for Vector2
impl DivAssign<f32> for Vector2
Source§fn div_assign(&mut self, right: f32)
fn div_assign(&mut self, right: f32)
/= operation. Read moreSource§impl ExpressionVariantValue for Vector2
impl ExpressionVariantValue for Vector2
Source§const FFI_VARIANT_TYPE: Option<VariantType>
const FFI_VARIANT_TYPE: Option<VariantType>
None when the type cannot be a foreign function parameter.Source§fn try_from_variant(v: &ExpressionVariant) -> Option<Self>
fn try_from_variant(v: &ExpressionVariant) -> Option<Self>
Source§fn into_variant(self) -> ExpressionVariant
fn into_variant(self) -> ExpressionVariant
Source§impl From<Vector2> for ExpressionVariant
impl From<Vector2> for ExpressionVariant
Source§fn from(value: Vector2) -> ExpressionVariant
fn from(value: Vector2) -> ExpressionVariant
Source§impl IInterpolator<Vector2> for Vector2Interpolator
impl IInterpolator<Vector2> for Vector2Interpolator
Source§impl MulAssign for Vector2
impl MulAssign for Vector2
Source§fn mul_assign(&mut self, right: Vector2)
fn mul_assign(&mut self, right: Vector2)
*= operation. Read moreSource§impl MulAssign<f32> for Vector2
impl MulAssign<f32> for Vector2
Source§fn mul_assign(&mut self, right: f32)
fn mul_assign(&mut self, right: f32)
*= operation. Read moreimpl StructuralPartialEq for Vector2
Auto Trait Implementations§
impl Freeze for Vector2
impl RefUnwindSafe for Vector2
impl Send for Vector2
impl Sync for Vector2
impl Unpin for Vector2
impl UnsafeUnpin for Vector2
impl UnwindSafe for Vector2
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more