pub struct Vector {
pub x: f64,
pub y: f64,
}Expand description
Defines a vector.
Fields§
§x: f64The X component.
y: f64The Y component.
Implementations§
Source§impl Vector
impl Vector
Sourcepub fn squared_length(&self) -> f64
pub fn squared_length(&self) -> f64
Squared length of the vector.
Sourcepub fn equals(&self, other: Vector) -> bool
pub fn equals(&self, other: Vector) -> bool
Check if two vectors are equal (exact comparison of the components).
Sourcepub fn nearly_equals(&self, other: Vector) -> bool
pub fn nearly_equals(&self, other: Vector) -> bool
Check if two vectors are nearly equal (numerically).
Sourcepub const fn with_x(&self, x: f64) -> Vector
pub const fn with_x(&self, x: f64) -> Vector
Returns a new vector with the specified X component.
Sourcepub const fn with_y(&self, y: f64) -> Vector
pub const fn with_y(&self, y: f64) -> Vector
Returns a new vector with the specified Y component.
Sourcepub fn normalize(&self) -> Vector
pub fn normalize(&self) -> Vector
Returns a normalized version of this vector. A zero-length vector yields NaN components.
Sourcepub fn normalize_vector(vector: Vector) -> Vector
pub fn normalize_vector(vector: Vector) -> Vector
Normalizes the given vector (static form of normalize).
Sourcepub fn divide(a: Vector, b: Vector) -> Vector
pub fn divide(a: Vector, b: Vector) -> Vector
Divides the first vector by the second, component-wise.
Sourcepub fn divide_scalar(vector: Vector, scalar: f64) -> Vector
pub fn divide_scalar(vector: Vector, scalar: f64) -> Vector
Divides the vector by the given scalar.
Sourcepub fn multiply(a: Vector, b: Vector) -> Vector
pub fn multiply(a: Vector, b: Vector) -> Vector
Multiplies the first vector by the second, component-wise.
Sourcepub fn multiply_scalar(vector: Vector, scalar: f64) -> Vector
pub fn multiply_scalar(vector: Vector, scalar: f64) -> Vector
Multiplies the vector by the given scalar.
Sourcepub fn negate_vector(vector: Vector) -> Vector
pub fn negate_vector(vector: Vector) -> Vector
Negates the vector (static form of negate).
Sourcepub const fn deconstruct(&self) -> (f64, f64)
pub const fn deconstruct(&self) -> (f64, f64)
Deconstructs the vector into its X and Y components.
Sourcepub fn abs(&self) -> Vector
pub fn abs(&self) -> Vector
Returns a vector whose elements are the absolute values of each of the specified vector’s elements.
Sourcepub fn clamp(value: Vector, min: Vector, max: Vector) -> Vector
pub fn clamp(value: Vector, min: Vector, max: Vector) -> Vector
Restricts a vector between a minimum and a maximum value.
Sourcepub fn max(left: Vector, right: Vector) -> Vector
pub fn max(left: Vector, right: Vector) -> Vector
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
Sourcepub fn min(left: Vector, right: Vector) -> Vector
pub fn min(left: Vector, right: Vector) -> Vector
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
Sourcepub fn distance(value1: Vector, value2: Vector) -> f64
pub fn distance(value1: Vector, value2: Vector) -> f64
Computes the Euclidean distance between the two given points.
Sourcepub fn distance_squared(value1: Vector, value2: Vector) -> f64
pub fn distance_squared(value1: Vector, value2: Vector) -> f64
Returns the Euclidean distance squared between two specified points.
Trait Implementations§
Source§impl AddAssign for Vector
impl AddAssign for Vector
Source§fn add_assign(&mut self, b: Vector)
fn add_assign(&mut self, b: Vector)
+= operation. Read moreSource§impl AddAssign<Vector> for Point
impl AddAssign<Vector> for Point
Source§fn add_assign(&mut self, b: Vector)
fn add_assign(&mut self, b: Vector)
+= operation. Read moreSource§impl BatchValue for Vector
impl BatchValue for Vector
impl Copy for Vector
Source§impl DivAssign<Vector> for Rect
impl DivAssign<Vector> for Rect
Source§fn div_assign(&mut self, scale: Vector)
fn div_assign(&mut self, scale: Vector)
/= operation. Read moreSource§impl DivAssign<Vector> for Size
impl DivAssign<Vector> for Size
Source§fn div_assign(&mut self, scale: Vector)
fn div_assign(&mut self, scale: Vector)
/= operation. Read moreSource§impl DivAssign<f64> for Vector
impl DivAssign<f64> for Vector
Source§fn div_assign(&mut self, scale: f64)
fn div_assign(&mut self, scale: f64)
/= operation. Read moreSource§impl ExpressionVariantValue for Vector
impl ExpressionVariantValue for Vector
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<Vector> for ExpressionVariant
impl From<Vector> for ExpressionVariant
Source§fn from(value: Vector) -> ExpressionVariant
fn from(value: Vector) -> ExpressionVariant
Source§impl IInterpolator<Vector> for VectorInterpolator
impl IInterpolator<Vector> for VectorInterpolator
Source§impl MarkupTyped for Vector
impl MarkupTyped for Vector
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Source§impl MulAssign<Vector> for Rect
impl MulAssign<Vector> for Rect
Source§fn mul_assign(&mut self, scale: Vector)
fn mul_assign(&mut self, scale: Vector)
*= operation. Read moreSource§impl MulAssign<Vector> for Size
impl MulAssign<Vector> for Size
Source§fn mul_assign(&mut self, scale: Vector)
fn mul_assign(&mut self, scale: Vector)
*= operation. Read moreSource§impl MulAssign<f64> for Vector
impl MulAssign<f64> for Vector
Source§fn mul_assign(&mut self, scale: f64)
fn mul_assign(&mut self, scale: f64)
*= operation. Read moreSource§impl ServerPropertyValue for Vector
impl ServerPropertyValue for Vector
impl StructuralPartialEq for Vector
Source§impl SubAssign for Vector
impl SubAssign for Vector
Source§fn sub_assign(&mut self, b: Vector)
fn sub_assign(&mut self, b: Vector)
-= operation. Read moreSource§impl SubAssign<Vector> for Point
impl SubAssign<Vector> for Point
Source§fn sub_assign(&mut self, b: Vector)
fn sub_assign(&mut self, b: Vector)
-= operation. Read moreSource§impl Transition<Vector> for VectorTransition
impl Transition<Vector> for VectorTransition
Source§fn do_transition(
this: &Self,
progress: Rc<dyn IObservable<f64>>,
old_value: Vector,
new_value: Vector,
) -> Rc<dyn IObservable<Vector>>
fn do_transition( this: &Self, progress: Rc<dyn IObservable<f64>>, old_value: Vector, new_value: Vector, ) -> Rc<dyn IObservable<Vector>>
old_value to new_value, driven by progress (from 0 to 1).Auto Trait Implementations§
impl Freeze for Vector
impl RefUnwindSafe for Vector
impl Send for Vector
impl Sync for Vector
impl Unpin for Vector
impl UnsafeUnpin for Vector
impl UnwindSafe for Vector
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