1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use {
super::{vec3_is_finite, Vec3},
serde::{Deserialize, Serialize},
};
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct Cone {
apex: Vec3,
height: f32,
normal: Vec3,
radius: f32,
}
impl Cone {
pub fn new(apex: Vec3, normal: Vec3, height: f32, radius: f32) -> Self {
assert!(vec3_is_finite(apex));
assert!(vec3_is_finite(normal));
assert!(normal.is_normalized());
assert!(height > 0.0);
assert!(radius > 0.0);
Self {
apex,
height,
normal,
radius,
}
}
pub const fn apex(&self) -> Vec3 {
self.apex
}
pub const fn height(&self) -> f32 {
self.height
}
pub const fn normal(&self) -> Vec3 {
self.normal
}
pub const fn radius(&self) -> f32 {
self.radius
}
}