region: add a WedgeZ
primitive
later i use this to Intersect a torus, thereby creating a torus which only sweeps out one particular arc angle.
This commit is contained in:
@@ -36,6 +36,31 @@ impl Display for CylinderZ {
|
||||
}
|
||||
}
|
||||
|
||||
/// describes all 3d space which falls within a given angular space, relative to the Z axis.
|
||||
#[derive(Copy, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct WedgeZ {
|
||||
arg_min: f32,
|
||||
arg_max: f32,
|
||||
}
|
||||
|
||||
impl WedgeZ {
|
||||
pub fn new(arg_min: f32, arg_max: f32) -> Self {
|
||||
Self { arg_min, arg_max }
|
||||
}
|
||||
}
|
||||
|
||||
impl Region for WedgeZ {
|
||||
fn contains(&self, p: Meters) -> bool {
|
||||
let arg = p.xy().arg();
|
||||
// arg is [-pi, pi).
|
||||
// if the user supplied some desired range where arg_max > pi, then we need to rotate
|
||||
// one revolution "into" that range.
|
||||
let arg_next = arg + f32::two_pi();
|
||||
(arg >= self.arg_min && arg <= self.arg_max) ||
|
||||
(arg_next >= self.arg_min && arg_next <= self.arg_max)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Torus {
|
||||
center: Meters,
|
||||
|
Reference in New Issue
Block a user