dyna3/app-proto/inversive-display/src/engine.rs
Aaron Fenyes 5bf23fa789 Ray-caster: pass spheres in through uniforms
Keep the hard-coded spheres for comparison.
2024-08-25 21:40:59 -07:00

12 lines
No EOL
398 B
Rust

use nalgebra::DVector;
pub fn sphere(center_x: f64, center_y: f64, center_z: f64, radius: f64) -> DVector<f64> {
let center_norm_sq = center_x * center_x + center_y * center_y + center_z * center_z;
DVector::from_column_slice(&[
center_x / radius,
center_y / radius,
center_z / radius,
0.5 / radius,
0.5 * (center_norm_sq / radius - radius)
])
}