Added ray module
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -1,7 +1,11 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
#![allow(unused_imports)]
|
||||||
|
//Use our ray module
|
||||||
mod ray;
|
mod ray;
|
||||||
use nalgebra::{Matrix4, Vector4};
|
|
||||||
use ray::Ray;
|
use ray::Ray;
|
||||||
|
//Use linear algebra module
|
||||||
|
use nalgebra::Vector4;
|
||||||
|
//Use modules for wgpu
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
@@ -9,8 +13,8 @@ use winit::{
|
|||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//MAIN ---------------------------------------------------------------------------------
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = Vector4::new(1.0, 1.0, 1.0, 1.0);
|
println!("Hello world");
|
||||||
let mat_a = Matrix4::from_diagonal_element(0.12);
|
|
||||||
println!("mat_a*x = {}", { mat_a * x });
|
|
||||||
}
|
}
|
||||||
|
//NEXT ---------------------------------------------------------------------------------
|
||||||
|
|||||||
15
src/ray.rs
Normal file
15
src/ray.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
use nalgebra::Vector4;
|
||||||
|
|
||||||
|
pub struct Ray {
|
||||||
|
a: Vector4<f32>,
|
||||||
|
b: Vector4<f32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ray {
|
||||||
|
fn new(_a: Vector4<f32>, _b: Vector4<f32>) -> Ray {
|
||||||
|
Ray { a: _a, b: _b }
|
||||||
|
}
|
||||||
|
fn at_t(self, t: f32) -> Vector4<f32> {
|
||||||
|
self.a + self.b * t
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user