chemrust_nasl/geometry/primitives/sphere/
mod.rs

1use nalgebra::{Point3, UnitVector3};
2
3#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
4pub struct Sphere {
5    center: Point3<f64>,
6    radius: f64,
7}
8
9impl Sphere {
10    pub fn new(center: Point3<f64>, radius: f64) -> Self {
11        Self { center, radius }
12    }
13    pub fn point_at_surface(&self, direction: &UnitVector3<f64>) -> Point3<f64> {
14        self.center + direction.scale(self.radius)
15    }
16
17    pub fn center(&self) -> Point3<f64> {
18        self.center
19    }
20
21    pub fn radius(&self) -> f64 {
22        self.radius
23    }
24}