Choreonoid  1.8
PolyhedralRegion.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_UTIL_POLYHEDRAL_REGION_H
6 #define CNOID_UTIL_POLYHEDRAL_REGION_H
7 
8 #include "EigenTypes.h"
9 #include <vector>
10 
11 namespace cnoid {
12 
14 {
15 public:
17  PolyhedralRegion(const PolyhedralRegion& org) : planes(org.planes) { }
18  PolyhedralRegion& operator=(const PolyhedralRegion& org) { planes = org.planes; return *this; }
19 
20  struct Plane {
23  double d;
25  d = normal.dot(point);
26  }
27  };
28 
29  int numBoundingPlanes() const { return planes.size(); }
30 
31  void clear() { planes.clear(); }
32 
33  void addBoundingPlane(const Vector3& normal, const Vector3& point){
34  planes.push_back(Plane(normal, point));
35  }
36 
37  const Plane& plane(int index) const { return planes[index]; }
38 
39  bool checkInside(const Vector3& point) const {
40  for(size_t i=0; i < planes.size(); ++i){
41  const Plane& p = planes[i];
42  if(point.dot(p.normal) - p.d < 0.0){
43  return false;
44  }
45  }
46  return true;
47  }
48 
49 private:
50  std::vector<Plane> planes;
51 };
52 
53 }
54 
55 #endif
cnoid::PolyhedralRegion
Definition: PolyhedralRegion.h:13
cnoid::PolyhedralRegion::PolyhedralRegion
PolyhedralRegion(const PolyhedralRegion &org)
Definition: PolyhedralRegion.h:17
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::PolyhedralRegion::Plane::Plane
Plane(const Vector3 &normal, const Vector3 &point)
Definition: PolyhedralRegion.h:24
cnoid::PolyhedralRegion::Plane::normal
Vector3 normal
Definition: PolyhedralRegion.h:21
cnoid::PolyhedralRegion::Plane::point
Vector3 point
Definition: PolyhedralRegion.h:22
cnoid::PolyhedralRegion::checkInside
bool checkInside(const Vector3 &point) const
Definition: PolyhedralRegion.h:39
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::PolyhedralRegion::addBoundingPlane
void addBoundingPlane(const Vector3 &normal, const Vector3 &point)
Definition: PolyhedralRegion.h:33
cnoid::PolyhedralRegion::PolyhedralRegion
PolyhedralRegion()
Definition: PolyhedralRegion.h:16
cnoid::PolyhedralRegion::numBoundingPlanes
int numBoundingPlanes() const
Definition: PolyhedralRegion.h:29
cnoid::PolyhedralRegion::Plane
Definition: PolyhedralRegion.h:20
EigenTypes.h
cnoid::PolyhedralRegion::Plane::d
double d
Definition: PolyhedralRegion.h:23
cnoid::PolyhedralRegion::operator=
PolyhedralRegion & operator=(const PolyhedralRegion &org)
Definition: PolyhedralRegion.h:18
cnoid::PolyhedralRegion::plane
const Plane & plane(int index) const
Definition: PolyhedralRegion.h:37
cnoid::PolyhedralRegion::clear
void clear()
Definition: PolyhedralRegion.h:31