parry3d/shape/
half_space.rs1use crate::math::{Real, Vector};
3use na::Unit;
4
5#[cfg(feature = "rkyv")]
6use rkyv::{bytecheck, CheckBytes};
7
8#[derive(PartialEq, Debug, Clone, Copy)]
10#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
11#[cfg_attr(
12 feature = "rkyv",
13 derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize, CheckBytes),
14 archive(as = "Self")
15)]
16#[repr(C)]
17pub struct HalfSpace {
18 pub normal: Unit<Vector<Real>>,
20}
21
22impl HalfSpace {
23 #[inline]
25 pub fn new(normal: Unit<Vector<Real>>) -> HalfSpace {
26 HalfSpace { normal }
27 }
28
29 pub fn scaled(self, scale: &Vector<Real>) -> Option<Self> {
34 Unit::try_new(self.normal.component_mul(scale), 0.0).map(|normal| Self { normal })
35 }
36}