00001
00002
00003
00004
00005
00006
00007 #ifndef IMPALGEBRA_PLANE_3D_H
00008 #define IMPALGEBRA_PLANE_3D_H
00009
00010 #include "Vector3D.h"
00011 #include "BoundingBoxD.h"
00012
00013 IMPALGEBRA_BEGIN_NAMESPACE
00014
00015
00016
00017
00018 class IMPALGEBRAEXPORT Plane3D {
00019 public:
00020 Plane3D(){}
00021 Plane3D(const VectorD<3>& point_on_plane,const VectorD<3> &normal_to_plane);
00022 Plane3D(double distance_to_plane ,const VectorD<3> &normal_to_plane);
00023 VectorD<3> get_point_on_plane() const {return normal_*distance_;}
00024 const VectorD<3> &get_normal() const {return normal_;}
00025
00026 VectorD<3> get_projection(const VectorD<3> &p) const;
00027
00028
00029
00030
00031
00032
00033 bool get_is_above(const VectorD<3> &p) const;
00034
00035
00036 bool get_is_below(const VectorD<3> &p) const;
00037
00038 IMP_SHOWABLE
00039
00040
00041 Plane3D get_opposite() const {
00042 return Plane3D(-distance_, -normal_);
00043 }
00044 private:
00045 double distance_;
00046 VectorD<3> normal_;
00047 };
00048
00049
00050
00051
00052 inline double get_distance(const Plane3D& pln, const VectorD<3> &p) {
00053 return (pln.get_projection(p)-p).get_magnitude();
00054 }
00055
00056 IMP_AREA_GEOMETRY_METHODS(Plane3D,
00057 return std::numeric_limits<double>::infinity(),
00058 {
00059 VectorD<3> ip
00060 = get_ones_vector_d<3>(
00061 std::numeric_limits<double>::infinity());
00062 return BoundingBoxD<3>(ip)+ BoundingBox3D(-ip);
00063 });
00064 IMPALGEBRA_END_NAMESPACE
00065
00066 #endif