Vector

Struct Vector 

Source
pub struct Vector<T = FloatNum>
where T: Clone + Copy,
{ /* private fields */ }

Implementations§

Source§

impl<T: Clone + Copy> Vector<T>

Source

pub const fn new(x: T, y: T) -> Self

Source

pub fn clone_from(&mut self, other: &Self)

Source

pub fn x(&self) -> T

Source

pub fn set_x(&mut self, reducer: impl FnMut(T) -> T)

Source

pub fn y(&self) -> T

Source

pub fn set_y(&mut self, reducer: impl FnMut(T) -> T)

Source

pub fn to_point(&self) -> Point<T>

Source§

impl Vector<f32>

Source

pub fn abs(&self) -> f32

Source

pub fn normalize(&self) -> Vector<f32>

Source

pub fn rad(&self, vector: &Vector<f32>) -> f32

Source

pub fn affine_transformation_rotate(&self, rad: f32) -> Vector<f32>

Source

pub fn affine_transformation_rotate_self(&mut self, rad: f32)

Source

pub fn is_zero(&self) -> bool

Source

pub fn set_zero(&mut self)

Source§

impl Vector<f64>

Source

pub fn abs(&self) -> f64

Source

pub fn normalize(&self) -> Vector<f64>

Source

pub fn rad(&self, vector: &Vector<f64>) -> f64

Source

pub fn affine_transformation_rotate(&self, rad: f64) -> Vector<f64>

Source

pub fn affine_transformation_rotate_self(&mut self, rad: f64)

Source

pub fn is_zero(&self) -> bool

Source

pub fn set_zero(&mut self)

Trait Implementations§

Source§

impl<T> Add<&Vector<T>> for &Point<T>
where T: Clone + Copy + Add<Output = T>,

Source§

type Output = Point<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Vector<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&Vector<T>> for &Segment<T>
where T: Add<Output = T> + Clone + Copy,

Source§

type Output = Segment<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Vector<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&Vector<T>> for Point<T>
where T: Clone + Copy + Add<Output = T>,

Source§

type Output = Point<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Vector<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&Vector<T>> for Vector<T>
where T: Clone + Copy + Add<Output = T>,

Source§

type Output = Vector<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Vector<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<Vector<T>> for Point<T>
where T: Clone + Copy + Add<Output = T>,

Source§

type Output = Point<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add for Vector<T>
where T: Clone + Copy + Add<Output = T>,

Source§

type Output = Vector<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<&Vector<T>> for Point<T>
where T: Clone + Copy + Add<Output = T> + AddAssign<T>,

Source§

fn add_assign(&mut self, rhs: &Vector<T>)

Performs the += operation. Read more
Source§

impl<T> AddAssign<&Vector<T>> for Vector<T>
where T: Clone + Copy + AddAssign<T>,

Source§

fn add_assign(&mut self, rhs: &Vector<T>)

Performs the += operation. Read more
Source§

impl<T> AddAssign<Vector<T>> for Point<T>
where T: Clone + Copy + Add<Output = T> + AddAssign<T>,

Source§

fn add_assign(&mut self, rhs: Vector<T>)

Performs the += operation. Read more
Source§

impl<T> AddAssign for Vector<T>
where T: Clone + Copy + AddAssign<T>,

Source§

fn add_assign(&mut self, rhs: Vector<T>)

Performs the += operation. Read more
Source§

impl<T> BitXor for Vector<T>
where T: Mul<T, Output = T> + Sub<T, Output = T> + Clone + Copy, Self: Into<Vector3<T>>,

Source§

type Output = T

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T> Clone for Vector<T>
where T: Clone + Copy + Clone,

Source§

fn clone(&self) -> Vector<T>

Returns a duplicate 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<T> Debug for Vector<T>
where T: Clone + Copy + Debug,

Source§

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

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

impl<T> Default for Vector<T>
where T: Clone + Copy + Default,

Source§

fn default() -> Vector<T>

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

impl<T> Display for Vector<T>
where T: Display + Copy,

Source§

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

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

impl<T> Div<&T> for Vector<T>
where T: Div<Output = T> + Clone + Copy,

Source§

type Output = Vector<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<T> for Vector<T>
where T: Div<Output = T> + Clone + Copy,

Source§

type Output = Vector<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<&T> for Vector<T>
where T: Clone + Copy + DivAssign<T>,

Source§

fn div_assign(&mut self, rhs: &T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign<T> for Vector<T>
where T: Clone + Copy + DivAssign<T>,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T> From<&Segment<T>> for Vector<T>
where T: Neg<Output = T> + Sub<Output = T> + Clone + Copy,

Source§

fn from(segment: &Segment<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + Copy> From<[T; 2]> for Vector<T>

Source§

fn from([x, y]: [T; 2]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(&Point<T>, &Point<T>)> for Vector<T>
where T: Clone + Copy + Neg<Output = T> + Sub<Output = T>,

Source§

fn from((p1, p2): (&Point<T>, &Point<T>)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(Point<T>, Point<T>)> for Vector<T>
where T: Clone + Copy + Neg<Output = T> + Sub<Output = T>,

Source§

fn from((p1, p2): (Point<T>, Point<T>)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(T, T)> for Vector<T>
where T: Clone + Copy,

Source§

fn from((x, y): (T, T)) -> Self

Converts to this type from the input type.
Source§

impl From<AxisDirection> for Vector<f32>

Source§

fn from(axis: AxisDirection) -> Self

Converts to this type from the input type.
Source§

impl From<AxisDirection> for Vector<f64>

Source§

fn from(axis: AxisDirection) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vector<T>> for (T, T)
where T: Clone + Copy,

Source§

fn from(value: Vector<T>) -> Self

Converts to this type from the input type.
Source§

impl From<Vector<f64>> for Vector3<f64>

Source§

fn from(value: Vector<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vector> for Vector3<f32>

Source§

fn from(value: Vector) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + Copy> From<Vector3<T>> for Vector<T>

Source§

fn from(value: Vector3<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> Mul<&Vector<T>> for &Vector<T>
where T: Mul<Output = T> + Add<Output = T> + Clone + Copy,

Source§

type Output = T

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vector<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for Vector<T>
where T: Mul<Output = T> + Clone + Copy,

Source§

type Output = Vector<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul for Vector<T>
where T: Mul<Output = T> + Add<Output = T> + Clone + Copy,

Source§

type Output = T

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Vector<T>
where T: Clone + Copy + MulAssign<T>,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign for Vector<T>
where T: Clone + Copy + MulAssign<T>,

Source§

fn mul_assign(&mut self, rhs: Vector<T>)

Performs the *= operation. Read more
Source§

impl<T> Neg for Vector<T>
where T: Clone + Copy + Neg<Output = T>,

Source§

type Output = Vector<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> Not for Vector<T>
where T: Neg<Output = T> + Clone + Copy,

Source§

type Output = Vector<T>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for Vector<f32>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Vector<f64>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Shr<&Vector> for &Vector

Source§

type Output = f32

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: &Vector) -> Self::Output

Performs the >> operation. Read more
Source§

impl Shr for Vector

Source§

type Output = f32

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: Vector) -> Self::Output

Performs the >> operation. Read more
Source§

impl<T> Sub<&Vector<T>> for Point<T>
where T: Clone + Copy + Sub<Output = T>,

Source§

type Output = Point<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Vector<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<&Vector<T>> for Vector<T>
where T: Clone + Copy + Sub<Output = T>,

Source§

type Output = Vector<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Vector<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<Vector<T>> for Point<T>
where T: Clone + Copy + Sub<Output = T>,

Source§

type Output = Point<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub for Vector<T>
where T: Clone + Copy + Sub<Output = T>,

Source§

type Output = Vector<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<&Vector<T>> for Point<T>
where T: Clone + Copy + Sub<Output = T> + SubAssign<T>,

Source§

fn sub_assign(&mut self, rhs: &Vector<T>)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<&Vector<T>> for Vector<T>
where T: Clone + Copy + SubAssign<T>,

Source§

fn sub_assign(&mut self, rhs: &Vector<T>)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<Vector<T>> for Point<T>
where T: Clone + Copy + Sub<Output = T> + SubAssign<T>,

Source§

fn sub_assign(&mut self, rhs: Vector<T>)

Performs the -= operation. Read more
Source§

impl<T> SubAssign for Vector<T>
where T: Clone + Copy + SubAssign<T>,

Source§

fn sub_assign(&mut self, rhs: Vector<T>)

Performs the -= operation. Read more
Source§

impl<T> Copy for Vector<T>
where T: Clone + Copy + Copy,

Auto Trait Implementations§

§

impl<T> Freeze for Vector<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vector<T>
where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for Vector<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vector<T>
where T: UnwindSafe,

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

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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.

Source§

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

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.