KrisLibrary  1.0.0
Polyhedron3D.h
1 #ifndef MATH3D_POLYHEDRON3D_H
2 #define MATH3D_POLYHEDRON3D_H
3 
4 #include "Point.h"
5 #include "Plane3D.h"
6 
7 namespace Math3D {
8 
9 struct Line3D;
10 struct Segment3D;
11 struct AABB3D;
12 
20 {
23  void initialize(int numPlanes, int numVertices);
24  void resize(int numPlanes, int numVertices);
25  void cleanup();
26  void makeFromTriangles(const Point3D* p, int numVertices, int* triangles, int numFaces); //faces is of size numFaces*3
27  void setTransformed(const ConvexPolyhedron3D& in, const Matrix4& T);
28  void operator = (const ConvexPolyhedron3D&);
29  void getAABB(AABB3D&) const;
30 
31  bool intersects(const ConvexPolyhedron3D& other) const; //returns true if the polyhedra intersect
32  void planeExtents(const Plane3D& p,Real& dmin,Real& dmax) const;
33  bool planeSplits(const Plane3D& p) const; //returns true if the plane intersects this polyhedron
34  bool planePos(const Plane3D& p) const; //returns true if this poly is entirely on the positive side of the plane
35  bool planeNeg(const Plane3D& p) const; //returns true if this poly is entirely on the negative side of the plane
36  bool contains(const Point3D& v) const; //returns true if the point is contained
37  bool withinDistance(const Point3D& v, Real dist) const; //returns true if the point is within the given distance
38  Real planeDistance(const Point3D& v) const; //return the closest planar distance to this polyhedron
39  bool intersects(const Line3D& l, Real& tmin, Real& tmax) const;
40  bool intersects(const Line3D& l) const;
41  bool intersects(const Segment3D& l) const;
42 
43  bool Read(File& f);
44  bool Write(File& f) const;
45 
46  Plane3D* planes;
47  Point3D* vertices;
48  int numPlanes;
49  int numVertices;
50 };
51 
52 } //namespace Math3d
53 
54 #endif
55 
A 3D plane classRepresents plane with a normal and offset such that x on the plane satisfy dot(normal...
Definition: Plane3D.h:19
A 3D vector class.
Definition: math3d/primitives.h:136
A 3D axis-aligned bounding box.
Definition: AABB3D.h:13
A 4x4 matrix class.
Definition: math3d/primitives.h:626
A convex polyhedron given in a dual representation, planes and vertices of convex hull...
Definition: Polyhedron3D.h:19
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
A 3D line class.
Definition: Line3D.h:18
A cross-platform class for reading/writing binary data.
Definition: File.h:47
Definition: Segment3D.h:12