pub struct Vector2<T> {
pub x: T,
pub y: T,
}
Fields§
§x: T
§y: T
Implementations§
Source§impl<T: Add<Output = T> + Mul<Output = T> + Copy> Vector2<T>
impl<T: Add<Output = T> + Mul<Output = T> + Copy> Vector2<T>
Sourcepub fn square_magnitude(&self) -> T
pub fn square_magnitude(&self) -> T
Returns the value of (x * x) + (y * y). Integer types don’t implement sqrt so we can’t implement magnitude.
Source§impl<T: Mul<Output = T> + Add<Output = T> + Sub<Output = T> + Copy + PartialOrd> Vector2<T>
impl<T: Mul<Output = T> + Add<Output = T> + Sub<Output = T> + Copy + PartialOrd> Vector2<T>
Sourcepub fn square_distance(&self, from: &Vector2<T>) -> T
pub fn square_distance(&self, from: &Vector2<T>) -> T
Returns the value of (x_2 - x_1)^2 + (y_2 - y_1)^2. Integer types don’t implement sqrt so we can’t implement distance.
Trait Implementations§
Source§impl<T: Ord> Ord for Vector2<T>
impl<T: Ord> Ord for Vector2<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd> PartialOrd for Vector2<T>
impl<T: PartialOrd> PartialOrd for Vector2<T>
Source§impl Vector2ToDouble for Vector2<f32>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<f32>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<f64>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<f64>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<i128>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<i128>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<i16>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<i16>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<i32>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<i32>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<i64>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<i64>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<i8>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<i8>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<isize>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<isize>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<u128>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<u128>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<u16>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<u16>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<u32>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<u32>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<u64>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<u64>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<u8>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<u8>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.
Source§impl Vector2ToDouble for Vector2<usize>
Convert a Vector<$m> to its f64 (double) representation.
impl Vector2ToDouble for Vector2<usize>
Convert a Vector<$m> to its f64 (double) representation.
§Panics
Panics whenever converting $m to f64 by writing $m as f64
would fail.