1use crate::{ShapeType, shape::Shape};
2
3#[derive(PartialEq, Debug, Copy, Clone)]
5pub struct Sphere {
6 pub radius: f32,
8}
9
10impl Sphere {
11 pub fn new(radius: f32) -> Self {
17 Sphere { radius }
18 }
19}
20
21impl Shape for Sphere {
22 fn is_convex(&self) -> bool {
23 true
24 }
25
26 fn clone_box(&self) -> Box<dyn Shape + Send + Sync> {
27 Box::new(*self)
28 }
29
30 fn get_shape_type(&self) -> ShapeType {
31 ShapeType::Sphere
32 }
33
34 fn get_radius(&self) -> Option<f32> {
35 Some(self.radius)
36 }
37}