[][src]Struct ico_math::Vector2

#[repr(C)]
pub struct Vector2 {
    pub data: __m128,
}

A vector of 2 floats (x,y).

Fields

data: __m128

Methods

impl Vector2[src]

pub fn new(x: f32, y: f32) -> Vector2[src]

Construct a new vector from f32 components.

pub fn set<T: Into<FloatVector>>(value: T) -> Vector2[src]

Set all values of the vector to the same f32 value.

pub fn zero() -> Vector2[src]

Construct a new vector of zeros.

pub fn x(self) -> FloatVector[src]

Get the x value of the vector, broadcast to all components as a FloatVector (xxxx).

pub fn y(self) -> FloatVector[src]

Get the y value of the vector, broadcast to all components as a FloatVector (yyyy).

pub fn load(raw: &RawVector_f32) -> Vector2[src]

Load a value from aligned memory.

pub fn store(self, dst: &mut RawVector_f32)[src]

Store a value to aligned memory.

pub fn set_x<T: Into<FloatVector>>(&mut self, value: T)[src]

Set the x value of this vector, leaving the other components unchanged.

pub fn set_y<T: Into<FloatVector>>(&mut self, value: T)[src]

Set the y value of this vector, leaving the other components unchanged.

pub fn dot(self, v1: Vector2) -> FloatVector[src]

Compute the 2 element dot-product, and return it as a broadcast FloatVector.

pub fn rotate<T: Into<FloatVector>>(self, radians: T) -> Vector2[src]

Rotate the vector by radians Right handed system, positive rotation is counterclockwise about the axis of rotation.

pub fn add(self, v2: Vector2) -> Vector2[src]

Compute the sum of two vectors and return it as a new vector.

pub fn sub(self, v2: Vector2) -> Vector2[src]

Subtract a vector and return it as a new vector.

pub fn mul(self, v2: Vector2) -> Vector2[src]

Multiply two vectors component-wise, and return it as a new vector.
(x1 * x2, y1 * y2, z1 * z2, w1 * w2)

pub fn div(self, v2: Vector2) -> Vector2[src]

Divide two vectors component-wise, and return it as a new vector.
(x1 / x2, y1 / y2, z1 / z2, w1 / w2)

pub fn mul_add(self, v2: Vector2, v3: Vector2) -> Vector2[src]

Fused Multiply Add. Result = (a * b) + c.

pub fn mul_sub(self, v2: Vector2, v3: Vector2) -> Vector2[src]

Fused Multiply Sub. Result = (a * b) - c.

pub fn neg_mul_add(self, v2: Vector2, v3: Vector2) -> Vector2[src]

Negated Fused Multiply Add. Result = -(a * b) + c.

pub fn neg_mul_sub(self, v2: Vector2, v3: Vector2) -> Vector2[src]

Negated Fused Multiply Sub. Result = -(a * b) - c.

pub fn and<T: SIMDVector2>(self, v2: T) -> Vector2[src]

Compute the bitwise AND of two vectors. This function treats inputs as binary data, and doesn't perform any conversions.

pub fn or<T: SIMDVector2>(self, v2: T) -> Vector2[src]

Compute the bitwise OR of two vectors. This function treats inputs as binary data, and doesn't perform any conversions.

pub fn andnot<T: SIMDVector2>(self, v2: T) -> Vector2[src]

Compute the bitwise ANDNOT of two vectors. This function treats inputs as binary data, and doesn't perform any conversions.

pub fn xor<T: SIMDVector2>(self, v2: T) -> Vector2[src]

Compute the bitwise XOR of two vectors. This function treats inputs as binary data, and doesn't perform any conversions.

pub fn equal(self, v2: Vector2) -> Vector2Bool[src]

Equals, computed component-wise. This compares bits, and is exact.

pub fn not_equal(self, v2: Vector2) -> Vector2Bool[src]

NotEquals, computed component-wise. This compares bits, and is exact.

pub fn greater_equal(self, v2: Vector2) -> Vector2Bool[src]

Greater than or equal to, computed component-wise. This compares bits, and is exact.

pub fn greater(self, v2: Vector2) -> Vector2Bool[src]

Greater than, computed component-wise. This compares bits, and is exact.

pub fn less_equal(self, v2: Vector2) -> Vector2Bool[src]

Less than or equal to, computed component-wise. This compares bits, and is exact.

pub fn less(self, v2: Vector2) -> Vector2Bool[src]

Less than, computed component-wise. This compares bits, and is exact.

pub fn approx_equal(self, v2: Vector2) -> Vector2Bool[src]

Relative and absolute epsilon comparison.
Uses machine epsilon as absolute, and 4*machine epsilon for relative. return abs(a - b) <= max(machine_epsilon, (max( abs(a), abs(b) ) * relative_epsilon); Adapted from Knuth.
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

pub fn definitely_greater(self, v2: Vector2) -> Vector2Bool[src]

Adapted from Knuth with an added absolute epsilon return (a - b) > max(machine_epsilon, (max( abs(a), abs(b) ) * relative_epsilon);

pub fn definitely_less(self, v2: Vector2) -> Vector2Bool[src]

Adapted from Knuth with an added absolute epsilon return (a - b) > max(machine_epsilon, (max( abs(a), abs(b) ) * relative_epsilon);

pub fn abs(self) -> Vector2[src]

The absolute value of each component of the vector.

pub fn copysign(self, v2: Vector2) -> Vector2[src]

Take the magnitude of the first argument (self), and use the sign of the second argument to produce a new vector

pub fn floor(self) -> Vector2[src]

Floor function. Returns signed 0 when applicable.

pub fn ceil(self) -> Vector2[src]

Ceil function. Returns signed 0 when applicable.

pub fn round(self) -> Vector2[src]

Round to nearest even function. Returns signed 0 when applicable.

pub fn truncate(self) -> Vector2[src]

Truncate function.

pub fn floor_to_int(self) -> Vector2Int[src]

Convert to an integer vector using the floor function.

pub fn ceil_to_int(self) -> Vector2Int[src]

Convert to an integer vector using the ceil function.

pub fn round_to_int(self) -> Vector2Int[src]

Convert to an integer vector using the round function.

pub fn truncate_to_int(self) -> Vector2Int[src]

Convert to an integer vector using the truncate function.

pub fn frac(self) -> Vector2[src]

Compute the fractional component of each component Result = X - Floor(x)

pub fn sqrt(self) -> Vector2[src]

Compute the square root of each component

pub fn sin(self) -> Vector2[src]

Compute the approximate sin of each component

pub fn cos(self) -> Vector2[src]

Compute the approximate cos of each component

pub fn tan(self) -> Vector2[src]

Compute the approximate tan of each component

pub fn acos(self) -> Vector2[src]

Compute the approximate acos of each component

pub fn asin(self) -> Vector2[src]

Compute the approximate asin of each component

pub fn atan2(self, x: Vector2) -> Vector2[src]

pub fn max(self, v2: Vector2) -> Vector2[src]

Compute the component-wise max.

pub fn min(self, v2: Vector2) -> Vector2[src]

Compute the component-wise min.

pub fn horizontal_min(self) -> FloatVector[src]

pub fn horizontal_max(self) -> FloatVector[src]

pub fn select(self, v2: Vector2, mask: Vector2Bool) -> Vector2[src]

Choose component wise between A and B based on the mask. False = A, True = B.

pub fn lerp<T: Into<FloatVector>>(self, v2: Vector2, t: T) -> Vector2[src]

Linear interpolate from a to b based on a float.

pub fn normalize(self) -> Vector2[src]

Normalize the vector. Returns a zero vector if the result would be infinity or NAN.

pub fn normalize_length(self) -> (Vector2, FloatVector)[src]

Normalize the vector. Returns a zero vector if the result would be infinity or NAN. Also returns the length of the vector prior to normalization.

pub fn sqr_magnitude(self) -> FloatVector[src]

The square magnitude of the vector. Equal to Dot(self, self).

pub fn magnitude(self) -> FloatVector[src]

The magnitude of the vector. Equal to Sqrt(Dot(self, self)).

pub fn xxxx(self) -> Vector4[src]

pub fn yyyy(self) -> Vector4[src]

pub fn xx(self) -> Vector2[src]

pub fn xy(self) -> Vector2[src]

pub fn yx(self) -> Vector2[src]

pub fn yy(self) -> Vector2[src]

Trait Implementations

impl SIMDVector2 for Vector2[src]

impl Clone for Vector2[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl From<f32> for Vector2[src]

impl From<FloatVector> for Vector2[src]

impl From<Vector3> for Vector2[src]

impl From<Vector4> for Vector2[src]

impl From<Vector2Int> for Vector2[src]

impl From<Vector2> for Vector2Int[src]

impl From<Vector2> for Vector3[src]

impl From<Vector2> for Vector4[src]

impl PartialEq<Vector2> for Vector2[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Copy for Vector2[src]

impl Debug for Vector2[src]

impl<T: Into<FloatVector>> Div<T> for Vector2[src]

type Output = Vector2

The resulting type after applying the / operator.

impl Div<Vector2> for FloatVector[src]

type Output = Vector2

The resulting type after applying the / operator.

impl Add<Vector2> for Vector2[src]

type Output = Vector2

The resulting type after applying the + operator.

impl Sub<Vector2> for Vector2[src]

type Output = Vector2

The resulting type after applying the - operator.

impl<T: Into<FloatVector>> Mul<T> for Vector2[src]

type Output = Vector2

The resulting type after applying the * operator.

impl Mul<Vector2> for FloatVector[src]

type Output = Vector2

The resulting type after applying the * operator.

impl Neg for Vector2[src]

type Output = Vector2

The resulting type after applying the - operator.

impl AddAssign<Vector2> for Vector2[src]

impl SubAssign<Vector2> for Vector2[src]

impl<T: Into<FloatVector>> MulAssign<T> for Vector2[src]

impl<T: Into<FloatVector>> DivAssign<T> for Vector2[src]

Auto Trait Implementations

impl Sync for Vector2

impl Send for Vector2

impl Unpin for Vector2

impl RefUnwindSafe for Vector2

impl UnwindSafe for Vector2

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]