//! Support mapping based Plane shape. use std::any::Any; use std::mem; use std::any::TypeId; use na; use inspection::{Repr, ReprDesc}; use math::{Vector, Point}; /// SupportMap description of a plane. #[derive(PartialEq, Debug, Clone, RustcEncodable, RustcDecodable)] pub struct Plane { /// The plane normal. normal: V } impl Plane { /// Builds a new plane from its center and its normal. #[inline] pub fn new(normal: V) -> Plane { unsafe { Plane::new_normalized(na::normalize(&normal)) } } } impl Plane { /// Builds a new plane from its center and its normal. #[inline] pub unsafe fn new_normalized(normal: V) -> Plane { Plane { normal: normal } } /// The plane normal. #[inline] pub fn normal(&self) -> &V { &self.normal } } impl Repr for Plane where P: Point { #[inline(always)] fn repr(&self) -> ReprDesc { unsafe { ReprDesc::new( TypeId::of::>(), TypeId::of::<&Any>(), mem::transmute(self as &Any) ) } } }