Struct dbsdk_rs::math::Vector2

source ·
#[repr(C)]
pub struct Vector2 { pub x: f32, pub y: f32, }

Fields§

§x: f32§y: f32

Implementations§

source§

impl Vector2

source

pub const fn new(x: f32, y: f32) -> Vector2

source

pub const fn zero() -> Vector2

source

pub const fn unit_x() -> Vector2

source

pub const fn unit_y() -> Vector2

source

pub fn distance_sq(lhs: &Vector2, rhs: &Vector2) -> f32

Compute the squared distance between two vectors

source

pub fn distance(lhs: &Vector2, rhs: &Vector2) -> f32

Compute the distance between two vectors

source

pub fn length_sq(self) -> f32

Compute the squared length of the vector

source

pub fn length(self) -> f32

Compute the length of the vector

source

pub fn normalize(&mut self)

Normalize the vector

source

pub fn normalized(&self) -> Vector2

Produce a normalized copy of the vector

source

pub fn dot(lhs: &Vector2, rhs: &Vector2) -> f32

Compute the dot product of two vectors

Trait Implementations§

source§

impl Add<Vector2> for Vector2

§

type Output = Vector2

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vector2) -> Vector2

Performs the + operation. Read more
source§

impl Clone for Vector2

source§

fn clone(&self) -> Vector2

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 Div<Vector2> for Vector2

§

type Output = Vector2

The resulting type after applying the / operator.
source§

fn div(self, rhs: Vector2) -> Vector2

Performs the / operation. Read more
source§

impl Div<Vector2> for f32

§

type Output = Vector2

The resulting type after applying the / operator.
source§

fn div(self, rhs: Vector2) -> Vector2

Performs the / operation. Read more
source§

impl Div<f32> for Vector2

§

type Output = Vector2

The resulting type after applying the / operator.
source§

fn div(self, rhs: f32) -> Vector2

Performs the / operation. Read more
source§

impl Mul<Vector2> for Vector2

§

type Output = Vector2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vector2) -> Vector2

Performs the * operation. Read more
source§

impl Mul<Vector2> for f32

§

type Output = Vector2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vector2) -> Vector2

Performs the * operation. Read more
source§

impl Mul<f32> for Vector2

§

type Output = Vector2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Vector2

Performs the * operation. Read more
source§

impl Sub<Vector2> for Vector2

§

type Output = Vector2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vector2) -> Vector2

Performs the - operation. Read more
source§

impl Copy for Vector2

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.