1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::settings::*;

/// A 2D column vector.
#[repr(C)]
#[derive(Debug, PartialEq, Default, Copy, Clone)]
pub struct Vec2 {
    pub x: Float32,
    pub y: Float32,
}

impl Vec2 {

	/// Construct using coordinates.
	pub fn new(x: f32, y: f32) -> Vec2 {
		Vec2 {x: x, y: y}
	}

	/// Set this vector to some specified coordinates.
	pub fn set(&mut self, x: f32, y: f32) {
		self.x = x;
		self.y = y;
	}

	/// Construct a vector with all zero coordinates.
	pub fn zero() -> Vec2 {
		Vec2::default()
	}
}