You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
573 B
23 lines
573 B
use crate::structs::Vec3;
|
|
use crate::object::Obj;
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
|
pub struct Cylinder {
|
|
center: Vec3,
|
|
radius: f64
|
|
}
|
|
|
|
impl Cylinder {
|
|
pub const fn new(center: Vec3, radius: f64) -> Cylinder {
|
|
Cylinder { center, radius }
|
|
}
|
|
}
|
|
|
|
impl Obj for Cylinder {
|
|
fn distance_to(&self, point: Vec3) -> f64 {
|
|
Vec3::new(self.center.x(), point.y(), self.center.z()).distance_to(point) - self.radius
|
|
}
|
|
fn normal_at(&self, point: Vec3) -> Vec3 {
|
|
point - Vec3::new(self.center.x(), point.y(),self.center.z())
|
|
}
|
|
}
|
|
|