diff options
author | eug-vs <eugene@eug-vs.xyz> | 2021-10-29 01:37:48 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2021-10-29 01:45:27 +0300 |
commit | aed3ae868a379b4ac98b3ec062ea1af3adffcb38 (patch) | |
tree | 9f4ad33696f6a786831eb0f2b8fa205e4aeb9d58 | |
parent | ea0e4d78415a7876803b6c83e3b95aade2d999b9 (diff) | |
download | pistol-aed3ae868a379b4ac98b3ec062ea1af3adffcb38.tar.gz |
feat!: remove unused code
-rw-r--r-- | src/canvas.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/vector.rs | 90 |
3 files changed, 0 insertions, 95 deletions
diff --git a/src/canvas.rs b/src/canvas.rs deleted file mode 100644 index 87413a1..0000000 --- a/src/canvas.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub struct Canvas { - pub width: u32, - pub height: u32, -} diff --git a/src/main.rs b/src/main.rs index e0b0fd9..da16e28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ extern crate ncurses; mod camera; -mod canvas; use std::{f32::consts::PI, time::Instant}; use cgmath::{Angle, InnerSpace, Matrix3, Rad, Vector3}; use ncurses::*; diff --git a/src/vector.rs b/src/vector.rs deleted file mode 100644 index c4ddaab..0000000 --- a/src/vector.rs +++ /dev/null @@ -1,90 +0,0 @@ -use std::fmt; -use std::ops; - -#[derive(Debug, Clone, Copy)] -pub struct Vector { - pub x: f32, - pub y: f32, - pub z: f32, -} - -impl fmt::Display for Vector { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "({:.2}, {:.2}, {:.2})", self.x, self.y, self.z) - } -} - -impl ops::Add for Vector { - type Output = Vector; - fn add(self, rhs: Self) -> Self::Output { - Vector { - x: self.x + rhs.x, - y: self.y + rhs.y, - z: self.z + rhs.z, - } - } -} - -impl ops::Sub for Vector { - type Output = Vector; - fn sub(self, rhs: Self) -> Self::Output { - Vector { - x: self.x - rhs.x, - y: self.y - rhs.y, - z: self.z - rhs.z, - } - } -} - -impl ops::Mul<f32> for Vector { - type Output = Vector; - fn mul(self, rhs: f32) -> Self::Output { - Vector { - x: self.x * rhs, - y: self.y * rhs, - z: self.z * rhs, - } - } -} - -impl ops::Div<f32> for Vector { - type Output = Vector; - fn div(self, rhs: f32) -> Self::Output { - Vector { - x: self.x / rhs, - y: self.y / rhs, - z: self.z / rhs, - } - } -} - -impl ops::Mul<Vector> for Vector { - type Output = f32; - fn mul(self, rhs: Vector) -> Self::Output { - self.x * rhs.x + self.y * rhs.y + self.z * rhs.z - } -} - -impl Vector { - pub fn magnitude_squared(self) -> f32 { - self.x * self.x + self.y * self.y + self.z * self.z - } - - pub fn magnitude(self) -> f32 { - self.magnitude_squared().sqrt() - } - - pub fn normalized(self) -> Vector { - let mag = self.magnitude(); - self / mag - } - - pub fn rotate_z(self, angle: f32) -> Vector { - // TODO: multiply by a matirx - Vector { - x: self.x * angle.cos() + self.y * angle.sin(), - y: self.y * angle.cos() - self.x * angle.sin(), - z: self.z, - } - } -} |