Type Definition olc_pixel_game_engine::Vi2d

source ·
pub type Vi2d = V2d<i32>;
Expand description

Mirror of olc::vi2d. A 2D integer vector type. Implements std::ops::Add, std::ops::Sub, std::ops::Mul, and std::ops::Div as well as all their assignment equivalents.

Example usage:

let mut a = Vi2d::new(1, 2) + Vi2d { x: 3, y: 4 };
a *= (2i32, 2i32).into();
assert_eq!(a, Vi2d::new(8, 12));

Implementations§

source§

impl Vi2d

source

pub fn mag(&self) -> i32

Returns magnitude (or length) of a vector.

source

pub fn mag2(&self) -> i32

Returns magnitude squared.

source

pub fn norm(&self) -> Self

Returns vector norm.

source

pub fn perp(&self) -> Self

Returns perpendicular vector.

source

pub fn dot(&self, rhs: Vi2d) -> i32

Returns dot product of two vectors.

source

pub fn cross(&self, rhs: Vi2d) -> i32

Returns cross product of two vectors.