Skip to content
Snippets Groups Projects
Commit dac1db4d authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[GL] Add a fast and non-robust version of orient2d

parent 7ee6f4e1
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@
#include "MathLib/GeometricBasics.h"
extern double orient2d(double *, double *, double *);
extern double orient2dfast(double*, double*, double*);
namespace ExactPredicates
{
......@@ -40,6 +41,15 @@ double getOrientation2d(MathLib::Point3d const& a,
const_cast<double*>(b.getCoords()),
const_cast<double*>(c.getCoords()));
}
double getOrientation2dFast(MathLib::Point3d const& a,
MathLib::Point3d const& b,
MathLib::Point3d const& c)
{
return orient2dfast(const_cast<double*>(a.getCoords()),
const_cast<double*>(b.getCoords()),
const_cast<double*>(c.getCoords()));
}
}
namespace GeoLib
......@@ -56,6 +66,19 @@ Orientation getOrientation(MathLib::Point3d const& p0,
return COLLINEAR;
}
Orientation getOrientationFast(MathLib::Point3d const& p0,
MathLib::Point3d const& p1,
MathLib::Point3d const& p2)
{
double const orientation =
ExactPredicates::getOrientation2dFast(p0, p1, p2);
if (orientation > 0)
return CCW;
if (orientation < 0)
return CW;
return COLLINEAR;
}
bool parallel(MathLib::Vector3 v, MathLib::Vector3 w)
{
const double eps(std::numeric_limits<double>::epsilon());
......
......@@ -39,13 +39,21 @@ enum Orientation
};
/**
* Computes the orientation of the three 2D-Points.
* Computes the orientation of the three 2D-Points. This is a robust method.
* \returns CW (clockwise), CCW (counterclockwise) or COLLINEAR (points are on a
* line)
*/
Orientation getOrientation(MathLib::Point3d const& p0,
MathLib::Point3d const& p1,
MathLib::Point3d const& p2);
/**
* Computes the orientation of the three 2D-Points. This is a non-robust method.
* \returns CW (clockwise), CCW (counterclockwise) or COLLINEAR (points are on a
* line)
*/
Orientation getOrientationFast(MathLib::Point3d const& p0,
MathLib::Point3d const& p1,
MathLib::Point3d const& p2);
/**
* compute a supporting plane (represented by plane_normal and the value d) for the polygon
* Let \f$n\f$ be the plane normal and \f$d\f$ a parameter. Then for all points \f$p \in R^3\f$ of the plane
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment