KrisLibrary  1.0.0
geometry/primitives.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_PRIMITIVES_H
2 #define GEOMETRY_PRIMITIVES_H
3 
4 #include <KrisLibrary/math3d/geometry2d.h>
5 #include <KrisLibrary/math3d/geometry3d.h>
6 
15 namespace Geometry {
16 
17  using namespace Math3D;
18 
21 
23 inline bool Lexical2DOrder (const Point2D& p1,const Point2D& p2)
24 {
25  if(p1.x < p2.x) return true;
26  else if(p1.x > p2.x) return false;
27  return (p1.y < p2.y);
28 }
29 
31 inline bool Lexical3DOrder (const Point3D& p1,const Point3D& p2)
32 {
33  if(p1.x < p2.x) return true;
34  else if(p1.x > p2.x) return false;
35  if(p1.y < p2.y) return true;
36  else if(p1.y > p2.y) return false;
37  return (p1.z < p2.z);
38 }
39 
47 inline Real Orient2D(const Point2D& p0, const Point2D& p1, const Point2D& p2)
48 {
49  return (p1.x - p0.x)*(p2.y - p0.y) - (p2.x - p0.x)*(p1.y - p0.y);
50 }
51 
52 
56 {
57  inline Angular2DOrdering(const Point2D& _p0) :p0(_p0) {}
58  inline bool operator () (const Point2D& p1,const Point2D& p2) const
59  {
60  return Orient2D(p0,p1,p2) > 0;
61  }
62  Point2D p0;
63 };
64 
67 } // namespace Geometry
68 
69 #endif
A 3D vector class.
Definition: math3d/primitives.h:136
Real Orient2D(const Point2D &p0, const Point2D &p1, const Point2D &p2)
Orientation of p2 relative to p1, relative to p0.
Definition: geometry/primitives.h:47
bool Lexical3DOrder(const Point3D &p1, const Point3D &p2)
Lexical < order on 3D points.
Definition: geometry/primitives.h:31
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:12
Definition: geometry/primitives.h:55
bool Lexical2DOrder(const Point2D &p1, const Point2D &p2)
Lexical < order on 2D points.
Definition: geometry/primitives.h:23
A 2D vector class.
Definition: math3d/primitives.h:41
Contains all definitions in the Geometry package.
Definition: AnyGeometry.h:11