Struct box2d_rs::b2_math::B2vec2

source ·
pub struct B2vec2 {
    pub x: f32,
    pub y: f32,
}
Expand description

A 2D column vector.

Fields§

§x: f32§y: f32

Implementations§

source§

impl B2vec2

source

pub fn new(x_in: f32, y_in: f32) -> B2vec2

Construct using coordinates.

source

pub fn zero() -> B2vec2

source

pub fn set_zero(&mut self)

Set this vector to all zeros.

source

pub fn set(&mut self, x_: f32, y_: f32)

Set this vector to some specified coordinates.

source

pub fn get(self, i: i32) -> f32

source

pub fn set_by_index(&mut self, i: i32, value: f32)

source

pub fn length(self) -> f32

Get the length of this vector (the norm).

source

pub fn length_squared(self) -> f32

Get the length squared. For performance, use this instead of B2vec2::length (if possible).

source

pub fn normalize(&mut self) -> f32

Convert this vector into a unit vector. Returns the length.

source

pub fn is_valid(self) -> bool

Does this vector contain finite coordinates?

source

pub fn skew(self) -> B2vec2

Get the skew vector such that dot(skew_vec, other) == cross(vec, other)

Trait Implementations§

source§

impl Add<B2vec2> for B2vec2

source§

fn add(self, b: B2vec2) -> B2vec2

Add two vectors component-wise.

§

type Output = B2vec2

The resulting type after applying the + operator.
source§

impl AddAssign<B2vec2> for B2vec2

source§

fn add_assign(&mut self, other: B2vec2)

Add a vector to this vector.

source§

impl Clone for B2vec2

source§

fn clone(&self) -> B2vec2

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 Debug for B2vec2

source§

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

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

impl Default for B2vec2

source§

fn default() -> B2vec2

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

impl Mul<B2vec2> for f32

§

type Output = B2vec2

The resulting type after applying the * operator.
source§

fn mul(self, a: B2vec2) -> B2vec2

Performs the * operation. Read more
source§

impl MulAssign<f32> for B2vec2

source§

fn mul_assign(&mut self, other: f32)

Multiply this vector by a scalar.

source§

impl Neg for B2vec2

source§

fn neg(self) -> B2vec2

Negate this vector.

§

type Output = B2vec2

The resulting type after applying the - operator.
source§

impl PartialEq<B2vec2> for B2vec2

source§

fn eq(&self, other: &B2vec2) -> 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<B2vec2> for B2vec2

source§

fn sub(self, b: B2vec2) -> B2vec2

Subtract two vectors component-wise.

§

type Output = B2vec2

The resulting type after applying the - operator.
source§

impl SubAssign<B2vec2> for B2vec2

source§

fn sub_assign(&mut self, other: B2vec2)

Subtract a vector from this vector.

source§

impl Copy for B2vec2

source§

impl StructuralPartialEq for B2vec2

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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.