Struct physdes::vector2::Vector2

source ·
pub struct Vector2<T> {
    pub x_: T,
    pub y_: T,
}
Expand description

The code defines a generic struct called Vector2 with two fields, x_ and y_.

Properties:

  • x_: The x_ property represents the x-coordinate of the Vector2 object. It is of type T, which means it can be any type specified when creating an instance of the Vector2 struct.
  • y_: The y_ property is the y-coordinate of the Vector2 object. It represents the vertical position of the vector in a 2D coordinate system.

Fields§

§x_: T

x portion of the Vector2 object

§y_: T

y portion of the Vector2 object

Implementations§

source§

impl<T> Vector2<T>

source

pub const fn new(x_: T, y_: T) -> Self

The function new creates a new Vector2 with the given x and y values.

Arguments:

  • x_: The parameter x_ represents the x-coordinate of the Vector2.
  • y_: The parameter y_ represents the y-coordinate of the Vector2. It is of type T, which means it can be any type that is specified when the Vector2 is created.

Returns:

The new function is returning a new instance of the Vector2 struct with the provided x_ and y_ values.

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2), Vector2 { x_: 1, y_: 2 });
assert_eq!(Vector2::new(3, 4), Vector2 { x_: 3, y_: 4 });
source§

impl<T: Clone + Num> Vector2<T>

source

pub fn dot(&self, other: &Self) -> T

The dot function calculates the dot product of two vectors.

Arguments:

  • other: The other parameter is of the same type as self, which means it is an instance of the same struct or class that the dot method is defined in.

Returns:

The dot product of two vectors is being returned.

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2).dot(&Vector2::new(3, 4)), 11);
assert_eq!(Vector2::new(3, 4).dot(&Vector2::new(1, 2)), 11);
source

pub fn cross(&self, other: &Self) -> T

The cross function calculates the cross product of two vectors.

Arguments:

  • other: The other parameter is of type Self, which means it is the same type as the current object.

Returns:

The cross product of two vectors is being returned. Returns the cross product

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2).cross(&Vector2::new(3, 4)), -2);
assert_eq!(Vector2::new(3, 4).cross(&Vector2::new(1, 2)), 2);
source

pub fn norm_sqr(&self) -> T

The norm_sqr function calculates the square of the norm of a vector.

Returns:

The norm_sqr function returns the squared norm of the object on which it is called.

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2).norm_sqr(), 5);
assert_eq!(Vector2::new(3, 4).norm_sqr(), 25);
source

pub fn scale(&self, t: T) -> Self

The scale function multiplies the vector by a scalar value.

Arguments:

  • t: The parameter t is a scalar value that will be used to multiply each component of self.

Returns:

The scale method returns a new instance of the same type as self. Multiplies self by the scalar t.

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2).scale(3), Vector2::new(3, 6));
assert_eq!(Vector2::new(3, 4).scale(2), Vector2::new(6, 8));
source

pub fn unscale(&self, t: T) -> Self

The unscale function divides the coordinates of a vector by a scalar value.

Arguments:

  • t: The parameter t is a scalar value that is used to divide the self object. It is of type T, which is a generic type parameter. The division operation is performed on the x_ and y_ fields of the self object.

Returns:

The unscale method returns a new instance of the same type as self. Divides self by the scalar t.

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(3, 6).unscale(3), Vector2::new(1, 2));
assert_eq!(Vector2::new(6, 8).unscale(2), Vector2::new(3, 4));
source§

impl<T: Clone + Signed> Vector2<T>

source

pub fn l1_norm(&self) -> T

The l1_norm function calculates the Manhattan distance from the origin.

Returns:

The L1 norm, which is the Manhattan distance from the origin. Returns the L1 norm |x_| + |y_| – the Manhattan distance from the origin.

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2).l1_norm(), 3);
assert_eq!(Vector2::new(3, 4).l1_norm(), 7);
source§

impl<T: Clone + PartialOrd> Vector2<T>

source

pub fn norm_inf(&self) -> T

The norm_inf function returns the maximum absolute value between x_ and y_.

Returns:

The norm_inf function returns the maximum value between |x_| and |y_|. Returns the infinity norm max(|x_| + |y_|)

Example
use physdes::vector2::Vector2;

assert_eq!(Vector2::new(1, 2).norm_inf(), 2);
assert_eq!(Vector2::new(3, 4).norm_inf(), 4);

Trait Implementations§

source§

impl<'a, T: Clone + Num> Add<&'a Vector2<T>> for Point<T>

§

type Output = Point<T>

The resulting type after applying the + operator.
source§

fn add(self, other: &Vector2<T>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, T: Clone + Num> Add<&'a Vector2<T>> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the + operator.
source§

fn add(self, other: &Vector2<T>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, 'b, T: Clone + Num> Add<&'b Vector2<T>> for &'a Point<T>

§

type Output = Point<T>

The resulting type after applying the + operator.
source§

fn add(self, other: &Vector2<T>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, 'b, T: Clone + Num> Add<&'b Vector2<T>> for &'a Vector2<T>

source§

fn add(self, other: &Vector2<T>) -> Self::Output

The function clones the input arguments and calls the specified method on them.

Arguments:

  • other: A reference to another Vector2 object of the same type as self.
§

type Output = Vector2<T>

The resulting type after applying the + operator.
source§

impl<'a, T: Clone + Num> Add<Vector2<T>> for &'a Point<T>

§

type Output = Point<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Vector2<T>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, T: Clone + Num> Add<Vector2<T>> for &'a Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Vector2<T>) -> Self::Output

Performs the + operation. Read more
source§

impl<T: Clone + Num> Add<Vector2<T>> for Point<T>

source§

fn add(self, other: Vector2<T>) -> Self::Output

Translate a new Point

Examples
use physdes::point::Point;
use physdes::vector2::Vector2;

assert_eq!(Point::new(3, 4) + Vector2::new(5, 3), Point::new(8, 7));
assert_eq!(Point::new(3, 4) + Vector2::new(-5, -3), Point::new(-2, 1));
assert_eq!(Point::new(3, 4) + Vector2::new(5, -3), Point::new(8, 1));
assert_eq!(Point::new(3, 4) + Vector2::new(-5, 3), Point::new(-2, 7));
assert_eq!(Point::new(3, 4) + Vector2::new(0, 0), Point::new(3, 4));
assert_eq!(Point::new(3, 4) + Vector2::new(0, 5), Point::new(3, 9));
§

type Output = Point<T>

The resulting type after applying the + operator.
source§

impl<T: Clone + Num> Add<Vector2<T>> for Vector2<T>

source§

fn add(self, other: Self) -> Self::Output

The function add takes two values of the same type and returns their sum.

Arguments:

  • other: The other parameter is of the same type as self and represents the other object that you want to add to self.
Example
use physdes::vector2::Vector2;
use std::ops::Add;

assert_eq!(Vector2::new(1, 2).add(Vector2::new(3, 4)), Vector2::new(4, 6));
assert_eq!(Vector2::new(3, 4).add(Vector2::new(1, 2)), Vector2::new(4, 6));
§

type Output = Vector2<T>

The resulting type after applying the + operator.
source§

impl<'a, T: Clone + NumAssign> AddAssign<&'a Vector2<T>> for Point<T>

source§

fn add_assign(&mut self, other: &Vector2<T>)

Performs the += operation. Read more
source§

impl<'a, T: Clone + NumAssign> AddAssign<&'a Vector2<T>> for Vector2<T>

source§

fn add_assign(&mut self, other: &Self)

Performs the += operation. Read more
source§

impl<T: Clone + NumAssign> AddAssign<Vector2<T>> for Point<T>

source§

fn add_assign(&mut self, other: Vector2<T>)

Performs the += operation. Read more
source§

impl<T: Clone + NumAssign> AddAssign<Vector2<T>> for Vector2<T>

source§

fn add_assign(&mut self, other: Self)

The function add_assign adds the values of other.x_ and other.y_ to self.x_ and self.y_ respectively.

Arguments:

  • other: The “other” parameter is of type Self, which means it is a reference to another instance of the same struct or class that the method is defined in. In this case, it represents another instance of the struct or class that has the same fields or properties as self.
Example
use physdes::vector2::Vector2;
use std::ops::AddAssign;

let mut v = Vector2::new(1, 2);
let v2 = Vector2::new(3, 4);
v.add_assign(v2);
assert_eq!(v, Vector2::new(4, 6));
source§

impl<T: Clone> Clone for Vector2<T>

source§

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

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<T: Debug> Debug for Vector2<T>

source§

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

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

impl<T: Default> Default for Vector2<T>

source§

fn default() -> Vector2<T>

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

impl<T: Clone + Num> Div<T> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<'a, T: Clone + NumAssign> DivAssign<&'a T> for Vector2<T>

source§

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

Performs the /= operation. Read more
source§

impl<T: Clone + NumAssign> DivAssign<T> for Vector2<T>

source§

fn div_assign(&mut self, other: T)

The function divides the values of self.x_ and self.y_ by the value of other.

Arguments:

  • other: The parameter other is of type T, which means it can be any type that implements the Clone trait.
Example
use physdes::vector2::Vector2;
use std::ops::DivAssign;

let mut v = Vector2::new(3, 6);
v.div_assign(3);
assert_eq!(v, Vector2::new(1, 2));
source§

impl<T: Hash> Hash for Vector2<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, 'b, T: Clone + Num> Mul<&'a T> for &'b Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T: Clone + Num> Mul<&'a T> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<f32>> for &'b f32

§

type Output = Vector2<f32>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<f32>) -> Vector2<f32>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<f32>> for f32

§

type Output = Vector2<f32>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<f32>) -> Vector2<f32>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<f64>> for &'b f64

§

type Output = Vector2<f64>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<f64>) -> Vector2<f64>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<f64>> for f64

§

type Output = Vector2<f64>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<f64>) -> Vector2<f64>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<i128>> for &'b i128

§

type Output = Vector2<i128>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i128>) -> Vector2<i128>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<i128>> for i128

§

type Output = Vector2<i128>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i128>) -> Vector2<i128>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<i16>> for &'b i16

§

type Output = Vector2<i16>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i16>) -> Vector2<i16>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<i16>> for i16

§

type Output = Vector2<i16>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i16>) -> Vector2<i16>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<i32>> for &'b i32

§

type Output = Vector2<i32>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i32>) -> Vector2<i32>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<i32>> for i32

§

type Output = Vector2<i32>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i32>) -> Vector2<i32>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<i64>> for &'b i64

§

type Output = Vector2<i64>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i64>) -> Vector2<i64>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<i64>> for i64

§

type Output = Vector2<i64>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i64>) -> Vector2<i64>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<i8>> for &'b i8

§

type Output = Vector2<i8>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i8>) -> Vector2<i8>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<i8>> for i8

§

type Output = Vector2<i8>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<i8>) -> Vector2<i8>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<isize>> for &'b isize

§

type Output = Vector2<isize>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<isize>) -> Vector2<isize>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<isize>> for isize

§

type Output = Vector2<isize>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<isize>) -> Vector2<isize>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<u128>> for &'b u128

§

type Output = Vector2<u128>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u128>) -> Vector2<u128>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<u128>> for u128

§

type Output = Vector2<u128>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u128>) -> Vector2<u128>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<u16>> for &'b u16

§

type Output = Vector2<u16>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u16>) -> Vector2<u16>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<u16>> for u16

§

type Output = Vector2<u16>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u16>) -> Vector2<u16>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<u32>> for &'b u32

§

type Output = Vector2<u32>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u32>) -> Vector2<u32>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<u32>> for u32

§

type Output = Vector2<u32>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u32>) -> Vector2<u32>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<u64>> for &'b u64

§

type Output = Vector2<u64>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u64>) -> Vector2<u64>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<u64>> for u64

§

type Output = Vector2<u64>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u64>) -> Vector2<u64>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<u8>> for &'b u8

§

type Output = Vector2<u8>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u8>) -> Vector2<u8>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<u8>> for u8

§

type Output = Vector2<u8>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<u8>) -> Vector2<u8>

Performs the * operation. Read more
source§

impl<'a, 'b> Mul<&'a Vector2<usize>> for &'b usize

§

type Output = Vector2<usize>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<usize>) -> Vector2<usize>

Performs the * operation. Read more
source§

impl<'a> Mul<&'a Vector2<usize>> for usize

§

type Output = Vector2<usize>

The resulting type after applying the * operator.
source§

fn mul(self, other: &Vector2<usize>) -> Vector2<usize>

Performs the * operation. Read more
source§

impl<'a, T: Clone + Num> Mul<T> for &'a Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Clone + Num> Mul<T> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<f32>> for &'a f32

§

type Output = Vector2<f32>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<f32>) -> Vector2<f32>

Performs the * operation. Read more
source§

impl Mul<Vector2<f32>> for f32

§

type Output = Vector2<f32>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<f32>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<f64>> for &'a f64

§

type Output = Vector2<f64>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<f64>) -> Vector2<f64>

Performs the * operation. Read more
source§

impl Mul<Vector2<f64>> for f64

§

type Output = Vector2<f64>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<f64>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<i128>> for &'a i128

§

type Output = Vector2<i128>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i128>) -> Vector2<i128>

Performs the * operation. Read more
source§

impl Mul<Vector2<i128>> for i128

§

type Output = Vector2<i128>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i128>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<i16>> for &'a i16

§

type Output = Vector2<i16>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i16>) -> Vector2<i16>

Performs the * operation. Read more
source§

impl Mul<Vector2<i16>> for i16

§

type Output = Vector2<i16>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i16>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<i32>> for &'a i32

§

type Output = Vector2<i32>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i32>) -> Vector2<i32>

Performs the * operation. Read more
source§

impl Mul<Vector2<i32>> for i32

§

type Output = Vector2<i32>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i32>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<i64>> for &'a i64

§

type Output = Vector2<i64>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i64>) -> Vector2<i64>

Performs the * operation. Read more
source§

impl Mul<Vector2<i64>> for i64

§

type Output = Vector2<i64>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i64>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<i8>> for &'a i8

§

type Output = Vector2<i8>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i8>) -> Vector2<i8>

Performs the * operation. Read more
source§

impl Mul<Vector2<i8>> for i8

§

type Output = Vector2<i8>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<i8>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<isize>> for &'a isize

§

type Output = Vector2<isize>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<isize>) -> Vector2<isize>

Performs the * operation. Read more
source§

impl Mul<Vector2<isize>> for isize

§

type Output = Vector2<isize>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<isize>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<u128>> for &'a u128

§

type Output = Vector2<u128>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u128>) -> Vector2<u128>

Performs the * operation. Read more
source§

impl Mul<Vector2<u128>> for u128

§

type Output = Vector2<u128>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u128>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<u16>> for &'a u16

§

type Output = Vector2<u16>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u16>) -> Vector2<u16>

Performs the * operation. Read more
source§

impl Mul<Vector2<u16>> for u16

§

type Output = Vector2<u16>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u16>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<u32>> for &'a u32

§

type Output = Vector2<u32>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u32>) -> Vector2<u32>

Performs the * operation. Read more
source§

impl Mul<Vector2<u32>> for u32

§

type Output = Vector2<u32>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u32>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<u64>> for &'a u64

§

type Output = Vector2<u64>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u64>) -> Vector2<u64>

Performs the * operation. Read more
source§

impl Mul<Vector2<u64>> for u64

§

type Output = Vector2<u64>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u64>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<u8>> for &'a u8

§

type Output = Vector2<u8>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u8>) -> Vector2<u8>

Performs the * operation. Read more
source§

impl Mul<Vector2<u8>> for u8

§

type Output = Vector2<u8>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<u8>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a> Mul<Vector2<usize>> for &'a usize

§

type Output = Vector2<usize>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<usize>) -> Vector2<usize>

Performs the * operation. Read more
source§

impl Mul<Vector2<usize>> for usize

§

type Output = Vector2<usize>

The resulting type after applying the * operator.
source§

fn mul(self, other: Vector2<usize>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, T: Clone + NumAssign> MulAssign<&'a T> for Vector2<T>

source§

fn mul_assign(&mut self, other: &T)

Performs the *= operation. Read more
source§

impl<T: Clone + NumAssign> MulAssign<T> for Vector2<T>

source§

fn mul_assign(&mut self, other: T)

The function multiplies the values of self.x_ and self.y_ by the value of other.

Arguments:

  • other: The parameter other is of type T, which means it can be any type that implements the Clone trait.
Example
use physdes::vector2::Vector2;
use std::ops::MulAssign;

let mut v = Vector2::new(1, 2);
v.mul_assign(3);
assert_eq!(v, Vector2::new(3, 6));
source§

impl<'a, T: Clone + Num + Neg<Output = T>> Neg for &'a Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T: Clone + Num + Neg<Output = T>> Neg for Vector2<T>

source§

fn neg(self) -> Self::Output

The neg function returns a new instance of the same type with the negated values of x_ and y_.

Example
use physdes::vector2::Vector2;
use std::ops::Neg;

let v = Vector2::new(1, 2);
assert_eq!(-v, Vector2::new(-1, -2));
§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

impl<T: PartialEq> PartialEq<Vector2<T>> for Vector2<T>

source§

fn eq(&self, other: &Vector2<T>) -> 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<T: Clone + Num> Rem<T> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the % operator.
source§

fn rem(self, other: T) -> Self::Output

Performs the % operation. Read more
source§

impl<'a, T: Clone + Num> Sub<&'a Vector2<T>> for Point<T>

§

type Output = Point<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Vector2<T>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, T: Clone + Num> Sub<&'a Vector2<T>> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Vector2<T>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, 'b, T: Clone + Num> Sub<&'b Vector2<T>> for &'a Point<T>

§

type Output = Point<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: &Vector2<T>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, 'b, T: Clone + Num> Sub<&'b Vector2<T>> for &'a Vector2<T>

source§

fn sub(self, other: &Vector2<T>) -> Self::Output

The function clones the input arguments and calls the specified method on them.

Arguments:

  • other: A reference to another Vector2 object of the same type as self.
§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

impl<'a, T: Clone + Num> Sub<Vector2<T>> for &'a Point<T>

§

type Output = Point<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vector2<T>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, T: Clone + Num> Sub<Vector2<T>> for &'a Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vector2<T>) -> Self::Output

Performs the - operation. Read more
source§

impl<T: Clone + Num> Sub<Vector2<T>> for Point<T>

source§

fn sub(self, other: Vector2<T>) -> Self::Output

Translate a new Point

Examples
use physdes::point::Point;
use physdes::vector2::Vector2;
assert_eq!(Point::new(3, 4) - Vector2::new(5, 3), Point::new(-2, 1));
assert_eq!(Point::new(3, 4) - Vector2::new(-5, -3), Point::new(8, 7));
assert_eq!(Point::new(3, 4) - Vector2::new(5, -3), Point::new(-2, 7));
assert_eq!(Point::new(3, 4) - Vector2::new(-5, 3), Point::new(8, 1));
assert_eq!(Point::new(3, 4) - Vector2::new(0, 0), Point::new(3, 4));
assert_eq!(Point::new(3, 4) - Vector2::new(0, 5), Point::new(3, -1));
assert_eq!(Point::new(3, 4) - Vector2::new(5, 0), Point::new(-2, 4));
§

type Output = Point<T>

The resulting type after applying the - operator.
source§

impl<T: Clone + Num> Sub<Vector2<T>> for Vector2<T>

source§

fn sub(self, other: Self) -> Self::Output

The function subtracts the coordinates of two points and returns a new point.

Arguments:

  • other: The other parameter is of the same type as self and represents the other value that you want to subtract from self.
Example
use physdes::vector2::Vector2;
use std::ops::Sub;

assert_eq!(Vector2::new(1, 2).sub(Vector2::new(3, 4)), Vector2::new(-2, -2));
assert_eq!(Vector2::new(3, 4).sub(Vector2::new(1, 2)), Vector2::new(2, 2));
§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

impl<'a, T: Clone + NumAssign> SubAssign<&'a Vector2<T>> for Point<T>

source§

fn sub_assign(&mut self, other: &Vector2<T>)

Performs the -= operation. Read more
source§

impl<'a, T: Clone + NumAssign> SubAssign<&'a Vector2<T>> for Vector2<T>

source§

fn sub_assign(&mut self, other: &Self)

Performs the -= operation. Read more
source§

impl<T: Clone + NumAssign> SubAssign<Vector2<T>> for Point<T>

source§

fn sub_assign(&mut self, other: Vector2<T>)

Performs the -= operation. Read more
source§

impl<T: Clone + NumAssign> SubAssign<Vector2<T>> for Vector2<T>

source§

fn sub_assign(&mut self, other: Self)

The function subtracts the values of another object from the values of the current object.

Arguments:

  • other: The parameter “other” is of type Self, which means it is a reference to another instance of the same struct or class that the method is defined in. In this case, it is a reference to another instance of the struct or class that has the same fields as self (x_ and y
Example
use physdes::vector2::Vector2;
use std::ops::SubAssign;
let mut v = Vector2::new(1, 2);
let v2 = Vector2::new(3, 4);
v.sub_assign(v2);
assert_eq!(v, Vector2::new(-2, -2));
source§

impl<T: Clone + Num> Zero for Vector2<T>

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T: Copy> Copy for Vector2<T>

source§

impl<T: Eq> Eq for Vector2<T>

source§

impl<T> StructuralEq for Vector2<T>

source§

impl<T> StructuralPartialEq for Vector2<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

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

impl<T, Rhs, Output> NumOps<Rhs, Output> for Twhere T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,