Added primitives

This commit is contained in:
STP
2023-11-12 02:06:46 -05:00
parent eab69336a1
commit dfc5d1ad23
4 changed files with 80 additions and 16 deletions

View File

@@ -2,10 +2,18 @@
#![allow(unused_imports)]
#![allow(unused_variables)]
//Use linear algebra module
pub mod state;
use state::run;
//Cameras
mod camera;
mod primitive;
mod ray;
mod state;
mod texture;
mod vertex;
const EPSILON: f32 = 1e-7;
fn main() {
pollster::block_on(run());
}

View File

@@ -1,15 +1,17 @@
use nalgebra::Vector4;
use crate::EPSILON;
use nalgebra::{Matrix4, Point3, Vector3};
pub struct Ray {
a: Vector4<f32>,
b: Vector4<f32>,
pub a: Point3<f32>,
pub b: Vector3<f32>,
}
impl Ray {
fn new(_a: Vector4<f32>, _b: Vector4<f32>) -> Ray {
pub fn new(_a: Point3<f32>, _b: Vector3<f32>) -> Ray {
Ray { a: _a, b: _b }
}
fn at_t(self, t: f32) -> Vector4<f32> {
pub fn at_t(self, t: f32) -> Point3<f32> {
self.a + self.b * t
}
}