From 943f54a4b8fa38b590afba1e011f6af48c489245 Mon Sep 17 00:00:00 2001 From: STP Date: Sat, 11 Nov 2023 00:41:03 -0500 Subject: [PATCH] Added ray module --- src/main.rs | 12 ++++++++---- src/ray.rs | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/ray.rs diff --git a/src/main.rs b/src/main.rs index 3e96ce9..903b7d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,11 @@ #![allow(dead_code)] +#![allow(unused_imports)] +//Use our ray module mod ray; -use nalgebra::{Matrix4, Vector4}; use ray::Ray; +//Use linear algebra module +use nalgebra::Vector4; +//Use modules for wgpu use std::borrow::Cow; use winit::{ event::{Event, WindowEvent}, @@ -9,8 +13,8 @@ use winit::{ window::Window, }; +//MAIN --------------------------------------------------------------------------------- fn main() { - let x = Vector4::new(1.0, 1.0, 1.0, 1.0); - let mat_a = Matrix4::from_diagonal_element(0.12); - println!("mat_a*x = {}", { mat_a * x }); + println!("Hello world"); } +//NEXT --------------------------------------------------------------------------------- diff --git a/src/ray.rs b/src/ray.rs new file mode 100644 index 0000000..e8fdb88 --- /dev/null +++ b/src/ray.rs @@ -0,0 +1,15 @@ +use nalgebra::Vector4; + +pub struct Ray { + a: Vector4, + b: Vector4, +} + +impl Ray { + fn new(_a: Vector4, _b: Vector4) -> Ray { + Ray { a: _a, b: _b } + } + fn at_t(self, t: f32) -> Vector4 { + self.a + self.b * t + } +}