Generation

generate functionSun, 13 Nov 2022

raymatch a cube

fn ray_cube_intersection(origin: &Point3<f64>, direction: &Vector3<f64>, vertex_a: &Point3<f64>, vertex_b: &Point3<f64>) -> Option<f64> { let mut t_min = -f64::INFINITY; let mut t_max = f64::INFINITY; for (i, a) in vertex_a.iter().enumerate() { let b = vertex_b[i]; let o = origin[i]; let d = direction[i]; if d.abs() < 1e-6 { if o < a || o > b { return None; } } else { let t0 = (a - o) / d; let t1 = (b - o) / d; if t0 > t1 { std::mem::swap(&mut t0, &mut t1); } t_min = t_min.max(t0); t_

Want to kickstart your project?Use the new AI Studio to create your code