Trait tinyraytracer::blocks::RayCollision [−][src]
pub trait RayCollision {
fn ray_intersect(&self, ray: &Ray) -> HitPoint;
fn collision_normal(&self, hit_point: Vec3) -> Vec3;
fn collision_material(&self, hit_point: Vec3) -> Material;
}We need to determine if a ray of light hits a specific object or not. This trait contains the logic of how to determine that.
Required methods
fn ray_intersect(&self, ray: &Ray) -> HitPoint[src]
fn collision_normal(&self, hit_point: Vec3) -> Vec3[src]
fn collision_material(&self, hit_point: Vec3) -> Material[src]
Implementors
impl RayCollision for Plane[src]
impl RayCollision for Plane[src]fn ray_intersect(&self, ray: &Ray) -> HitPoint[src]
fn collision_normal(&self, hit_point: Vec3) -> Vec3[src]
fn collision_material(&self, hit_point: Vec3) -> Material[src]
impl RayCollision for Rectangle2D[src]
impl RayCollision for Rectangle2D[src]fn ray_intersect(&self, ray: &Ray) -> HitPoint[src]
This is easy. We look for plane-ray intersection and check if it is withing the rectangle
fn collision_normal(&self, hit_point: Vec3) -> Vec3[src]
fn collision_material(&self, hit_point: Vec3) -> Material[src]
impl RayCollision for Sphere[src]
impl RayCollision for Sphere[src]In case of a sphere it’s pretty easy, we need to project the center of the sphere on the ray of light and see if the projection is inside the sphere