Struct kas::geom::Vec2

source ·
#[repr(C)]
pub struct Vec2(pub f32, pub f32);
Expand description

2D vector

Usually used as either a coordinate or a difference of coordinates, but may have some other uses.

Vectors are partially ordered and support component-wise comparison via methods like lhs.lt(rhs). The PartialOrd trait is not implemented since it implements lhs ≤ rhs as lhs < rhs || lhs == rhs which is wrong for vectors (consider for lhs = (0, 1), rhs = (1, 0)).

Tuple Fields§

§0: f32§1: f32

Implementations§

source§

impl Vec2

source

pub const ZERO: Vec2 = _

Zero

source

pub const ONE: Vec2 = _

One

source

pub const NEG_INFINITY: Vec2 = _

Negative infinity

source

pub const INFINITY: Vec2 = _

Positive infinity

source

pub const NAN: Vec2 = _

Not a Number (NaN)

source

pub const fn splat(value: f32) -> Vec2

Constructs a new instance with each element initialized to value.

source

pub fn min_comp(self) -> f32

Take the minimum component

source

pub fn max_comp(self) -> f32

Take the maximum component

source

pub fn min(self, other: Vec2) -> Vec2

Return the minimum, componentwise

source

pub fn max(self, other: Vec2) -> Vec2

Return the maximum, componentwise

source

pub fn abs(self) -> Vec2

Take the absolute value of each component

source

pub fn floor(self) -> Vec2

Take the floor of each component

source

pub fn ceil(self) -> Vec2

Take the ceiling of each component

source

pub fn round(self) -> Vec2

Round each component to the nearest integer

source

pub fn trunc(self) -> Vec2

Take the trunc of each component

source

pub fn fract(self) -> Vec2

Take the fract of each component

source

pub fn sign(self) -> Vec2

For each component, return ±1 with the same sign as self.

source

pub fn lt(self, rhs: Vec2) -> bool

True when for all components, lhs < rhs

source

pub fn le(self, rhs: Vec2) -> bool

True when for all components, lhs ≤ rhs

source

pub fn ge(self, rhs: Vec2) -> bool

True when for all components, lhs ≥ rhs

source

pub fn gt(self, rhs: Vec2) -> bool

True when for all components, lhs > rhs

source

pub fn complex_mul(self, rhs: Vec2) -> Vec2

Multiply two vectors as if they are complex numbers

source

pub fn complex_div(self, rhs: Vec2) -> Vec2

Divide by a second vector as if they are complex numbers

source

pub fn complex_inv(self) -> Vec2

Take the complex reciprocal

source

pub fn sum(self) -> f32

Return the sum of the terms

source

pub fn sum_square(self) -> f32

Return the sum of the square of the terms

source

pub fn extract<D>(self, dir: D) -> f32
where D: Directional,

Extract one component, based on a direction

This merely extracts the horizontal or vertical component. It never negates it, even if the axis is reversed.

Trait Implementations§

source§

impl Add<Vec2> for Quad

§

type Output = Quad

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vec2) -> <Quad as Add<Vec2>>::Output

Performs the + operation. Read more
source§

impl Add<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the + operator.
source§

fn add(self, rhs: f32) -> <Vec2 as Add<f32>>::Output

Performs the + operation. Read more
source§

impl Add for Vec2

§

type Output = Vec2

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vec2) -> <Vec2 as Add>::Output

Performs the + operation. Read more
source§

impl AddAssign<Vec2> for Quad

source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
source§

impl AddAssign<f32> for Vec2

source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
source§

impl AddAssign for Vec2

source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
source§

impl Clone for Vec2

source§

fn clone(&self) -> Vec2

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Conv<(f32, f32)> for Vec2

source§

fn conv(arg: (f32, f32)) -> Vec2

Convert from T to Self Read more
source§

fn try_conv(v: (f32, f32)) -> Result<Vec2, Error>

Try converting from T to Self Read more
source§

impl Conv<Coord> for Vec2

source§

fn try_conv(arg: Coord) -> Result<Vec2, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Offset> for Vec2

source§

fn try_conv(arg: Offset) -> Result<Vec2, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Size> for Vec2

source§

fn try_conv(arg: Size) -> Result<Vec2, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Vec2> for (f32, f32)

source§

fn conv(v: Vec2) -> (f32, f32)

Convert from T to Self Read more
source§

fn try_conv(v: Vec2) -> Result<(f32, f32), Error>

Try converting from T to Self Read more
source§

impl Conv<Vec2> for Vec2

source§

fn conv(size: Vec2) -> Vec2

Convert from T to Self Read more
source§

fn try_conv(v: Vec2) -> Result<Vec2, Error>

Try converting from T to Self Read more
source§

impl Conv<Vec2> for Vec2

source§

fn conv(size: Vec2) -> Vec2

Convert from T to Self Read more
source§

fn try_conv(v: Vec2) -> Result<Vec2, Error>

Try converting from T to Self Read more
source§

impl ConvApprox<DVec2> for Vec2

source§

fn try_conv_approx(size: DVec2) -> Result<Vec2, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl ConvApprox<Vec2> for Coord

source§

fn try_conv_approx(arg: Vec2) -> Result<Coord, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl ConvApprox<Vec2> for Offset

source§

fn try_conv_approx(arg: Vec2) -> Result<Offset, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl ConvApprox<Vec2> for Size

source§

fn try_conv_approx(arg: Vec2) -> Result<Size, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl ConvFloat<Vec2> for Coord

source§

fn try_conv_trunc(x: Vec2) -> Result<Coord, Error>

Try converting to integer with truncation Read more
source§

fn try_conv_nearest(x: Vec2) -> Result<Coord, Error>

Try converting to the nearest integer Read more
source§

fn try_conv_floor(x: Vec2) -> Result<Coord, Error>

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: Vec2) -> Result<Coord, Error>

Try convert the ceiling to an integer Read more
§

fn conv_trunc(x: T) -> Self

Convert to integer with truncatation Read more
§

fn conv_nearest(x: T) -> Self

Convert to the nearest integer Read more
§

fn conv_floor(x: T) -> Self

Convert the floor to an integer Read more
§

fn conv_ceil(x: T) -> Self

Convert the ceiling to an integer Read more
source§

impl ConvFloat<Vec2> for Offset

source§

fn try_conv_trunc(x: Vec2) -> Result<Offset, Error>

Try converting to integer with truncation Read more
source§

fn try_conv_nearest(x: Vec2) -> Result<Offset, Error>

Try converting to the nearest integer Read more
source§

fn try_conv_floor(x: Vec2) -> Result<Offset, Error>

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: Vec2) -> Result<Offset, Error>

Try convert the ceiling to an integer Read more
§

fn conv_trunc(x: T) -> Self

Convert to integer with truncatation Read more
§

fn conv_nearest(x: T) -> Self

Convert to the nearest integer Read more
§

fn conv_floor(x: T) -> Self

Convert the floor to an integer Read more
§

fn conv_ceil(x: T) -> Self

Convert the ceiling to an integer Read more
source§

impl ConvFloat<Vec2> for Size

source§

fn try_conv_trunc(x: Vec2) -> Result<Size, Error>

Try converting to integer with truncation Read more
source§

fn try_conv_nearest(x: Vec2) -> Result<Size, Error>

Try converting to the nearest integer Read more
source§

fn try_conv_floor(x: Vec2) -> Result<Size, Error>

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: Vec2) -> Result<Size, Error>

Try convert the ceiling to an integer Read more
§

fn conv_trunc(x: T) -> Self

Convert to integer with truncatation Read more
§

fn conv_nearest(x: T) -> Self

Convert to the nearest integer Read more
§

fn conv_floor(x: T) -> Self

Convert the floor to an integer Read more
§

fn conv_ceil(x: T) -> Self

Convert the ceiling to an integer Read more
source§

impl Debug for Vec2

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Vec2

source§

fn default() -> Vec2

Returns the “default value” for a type. Read more
source§

impl Div<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the / operator.
source§

fn div(self, rhs: f32) -> <Vec2 as Div<f32>>::Output

Performs the / operation. Read more
source§

impl Div for Vec2

§

type Output = Vec2

The resulting type after applying the / operator.
source§

fn div(self, rhs: Vec2) -> <Vec2 as Div>::Output

Performs the / operation. Read more
source§

impl From<(f32, f32)> for Vec2

source§

fn from(arg: (f32, f32)) -> Vec2

Converts to this type from the input type.
source§

impl From<LogicalSize> for Vec2

source§

fn from(_: LogicalSize) -> Vec2

Converts to this type from the input type.
source§

impl From<Vec2> for LogicalSize

source§

fn from(_: Vec2) -> LogicalSize

Converts to this type from the input type.
source§

impl From<Vec2> for Vec2

source§

fn from(size: Vec2) -> Vec2

Converts to this type from the input type.
source§

impl From<Vec2> for Vec2

source§

fn from(size: Vec2) -> Vec2

Converts to this type from the input type.
source§

impl Mul<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> <Vec2 as Mul<f32>>::Output

Performs the * operation. Read more
source§

impl Mul for Vec2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec2) -> <Vec2 as Mul>::Output

Performs the * operation. Read more
source§

impl Neg for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn neg(self) -> <Vec2 as Neg>::Output

Performs the unary - operation. Read more
source§

impl PartialEq for Vec2

source§

fn eq(&self, other: &Vec2) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub<Vec2> for Quad

§

type Output = Quad

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vec2) -> <Quad as Sub<Vec2>>::Output

Performs the - operation. Read more
source§

impl Sub<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: f32) -> <Vec2 as Sub<f32>>::Output

Performs the - operation. Read more
source§

impl Sub for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vec2) -> <Vec2 as Sub>::Output

Performs the - operation. Read more
source§

impl SubAssign<Vec2> for Quad

source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
source§

impl SubAssign<f32> for Vec2

source§

fn sub_assign(&mut self, rhs: f32)

Performs the -= operation. Read more
source§

impl SubAssign for Vec2

source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
source§

impl Copy for Vec2

source§

impl StructuralPartialEq for Vec2

Auto Trait Implementations§

§

impl RefUnwindSafe for Vec2

§

impl Send for Vec2

§

impl Sync for Vec2

§

impl Unpin for Vec2

§

impl UnwindSafe for Vec2

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<S, T> Cast<T> for S
where T: Conv<S>,

§

fn cast(self) -> T

Cast from Self to T Read more
§

fn try_cast(self) -> Result<T, Error>

Try converting from Self to T Read more
§

impl<S, T> CastApprox<T> for S
where T: ConvApprox<S>,

§

fn try_cast_approx(self) -> Result<T, Error>

Try approximate conversion from Self to T Read more
§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
§

impl<S, T> CastFloat<T> for S
where T: ConvFloat<S>,

§

fn cast_trunc(self) -> T

Cast to integer, truncating Read more
§

fn cast_nearest(self) -> T

Cast to the nearest integer Read more
§

fn cast_floor(self) -> T

Cast the floor to an integer Read more
§

fn cast_ceil(self) -> T

Cast the ceiling to an integer Read more
§

fn try_cast_trunc(self) -> Result<T, Error>

Try converting to integer with truncation Read more
§

fn try_cast_nearest(self) -> Result<T, Error>

Try converting to the nearest integer Read more
§

fn try_cast_floor(self) -> Result<T, Error>

Try converting the floor to an integer Read more
§

fn try_cast_ceil(self) -> Result<T, Error>

Try convert the ceiling to an integer Read more
§

impl<S, T> ConvApprox<S> for T
where T: Conv<S>,

§

fn try_conv_approx(x: S) -> Result<T, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: S) -> T

Converting from T to Self, allowing approximation of value Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: 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.
§

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.
§

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.
§

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.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,