40#ifndef GEOGRAM_NUMERICS_PREDICATES
41#define GEOGRAM_NUMERICS_PREDICATES
106 const double* p0,
const double* p1,
132 const double* p0,
const double* p1,
const double* p2,
133 const double* q0,
const double* q1,
161 const double* p0,
const double* p1,
162 const double* p2,
const double* p3,
163 const double* q0,
const double* q1,
const double* q2,
194 const double* p0,
const double* p1,
195 const double* p2,
const double* p3,
196 double h0,
double h1,
double h2,
double h3,
197 const double* q0,
const double* q1,
const double* q2,
230 const double* p1,
const double* p2,
231 const double* p3,
const double* p4,
232 const double* q0,
const double* q1,
233 const double* q2,
const double* q3,
264 const double* p1,
const double* p2,
265 const double* p3,
const double* p4
294 const double* p0,
const double* p1,
295 const double* p2,
const double* p3,
const double* p4
314 const double* p0,
const double* p1,
315 const double* p2,
const double* p3,
336 const double* p0,
const double* p1,
const double* p2,
357 const double* p0,
const double* p1,
const double* p2,
386 const double* p0,
const double* p1,
const double* p2,
388 double h0,
double h1,
double h2,
double h3,
402 const double* p0,
const double* p1,
const double* p2
442 const double* p0,
const double* p1,
443 const double* p2,
const double* p3,
444 double h0,
double h1,
double h2,
double h3
458 const double* p0,
const double* p1,
459 const double* p2,
const double* p3
474 const double* p0,
const double* p1,
475 const double* p2,
const double* p3
533 const double* p0,
const double* p1,
534 const double* p2,
const double* p3,
const double* p4,
535 double h0,
double h1,
double h2,
double h3,
double h4
559 const double* p0,
const double* p1,
560 const double* p2,
const double* p3,
const double* p4,
561 double h0,
double h1,
double h2,
double h3,
double h4
572 const double* p0,
const double* p1,
const double* p2
596 const double* p0,
const double* p1,
597 const double* p2,
const double* p3
624 const double* p0,
const double* p1,
625 const double* p2,
const double* p3,
638 const double* p0,
const double* p1,
const double* p2
649 const double* p0,
const double* p1,
const double* p2
688 const double* v0,
const double* v1,
const double* v2
744 const double* p0,
const double* p1,
745 const double* p2,
const double* p3
747 double a11 = p1[0] - p0[0] ;
748 double a12 = p1[1] - p0[1] ;
749 double a13 = p1[2] - p0[2] ;
751 double a21 = p2[0] - p0[0] ;
752 double a22 = p2[1] - p0[1] ;
753 double a23 = p2[2] - p0[2] ;
755 double a31 = p3[0] - p0[0] ;
756 double a32 = p3[1] - p0[1] ;
757 double a33 = p3[2] - p0[2] ;
808 const T& p0,
const T& p1,
const T& p2,
const T& p3
833 static const struct SOSInfo {
843 {1, 3, 2, NO_INDEX, Z, NO_INDEX,
POSITIVE},
844 {1, 2, 3, NO_INDEX, Y, NO_INDEX,
POSITIVE},
847 {1, 3, 2, NO_INDEX, X, NO_INDEX,
POSITIVE},
852 {1, 1, 3, NO_INDEX, Z, NO_INDEX,
POSITIVE},
853 {1, 3, 1, NO_INDEX, Y, NO_INDEX,
POSITIVE},
854 {1, 3, 0, NO_INDEX, Z, NO_INDEX,
POSITIVE},
855 {0,NO_INDEX,NO_INDEX,NO_INDEX,NO_INDEX,NO_INDEX,
NEGATIVE}
860 SOS sos(p0, p1, p2, p3);
863 const SOSInfo& I = sosInfo[k];
869 s = sos.orient_1d(I.v1, I.v2, I.ax1);
871 return Sign(I.sign*s);
875 s = sos.orient_2d(I.v1, I.v2, I.v3, I.ax1, I.ax2);
877 return Sign(I.sign*s);
887 namespace Permutation {
899 const T** orig,
const T** perm,
index_t n
904 for (
index_t i = 0; i < n; ++i) {
905 if ((visited >> i) & 1) {
910 for (
index_t j = i; !((visited >> j) & 1); ) {
913 j =
index_t(std::find(orig, orig + n, perm[j]) - orig);
916 if (len % 2 == 0) odd = !odd;
Utilities to write geometric predicates (Predicate Construction Kit).
#define geo_assert_not_reached
Sets a non reachable point in the program.
#define geo_debug_assert(x)
Verifies that a condition is met.
T * data()
Gets modifiable vector data.
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
Sign det_4d(const double *p0, const double *p1, const double *p2, const double *p3)
Computes the sign of the determinant of a 4x4 matrix formed by four 4d points.
Sign in_circle_3dlifted_SOS(const double *p0, const double *p1, const double *p2, const double *p3, double h0, double h1, double h2, double h3, bool SOS=true)
Tests whether a lifted 3d point is inside the circumscribed circle of a lifted 3d triangle.
Sign orient_3dlifted(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4, double h0, double h1, double h2, double h3, double h4)
Computes the 4d orientation test.
Sign orient_3d_SOS(const exact::vec3h &p0, const exact::vec3h &p1, const exact::vec3h &p2, const exact::vec3h &p3)
Computes the orientation predicate in 3d.
Sign dot_compare_3d(const double *v0, const double *v1, const double *v2)
Compares two dot products.
Sign side3_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *q0, const double *q1, const double *q2, coord_index_t DIM)
Computes the side of a point (given as the intersection between a facet and two bisectors) relative t...
Sign orient_3dlifted_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4, double h0, double h1, double h2, double h3, double h4)
Computes the 4d orientation test with symbolic perturbation.
Sign side4_3d_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4)
Computes the side of a point (given as the intersection between three bisectors) relative to another ...
Sign in_circle_2d_SOS(const double *p0, const double *p1, const double *p2, const double *p3)
Tests whether a 2d point is inside the circumscribed circle of a 3d triangle.
Sign orient_2dlifted_SOS(const double *p0, const double *p1, const double *p2, const double *p3, double h0, double h1, double h2, double h3)
Computes the 3d orientation test with lifted points.
Sign orient_3d_inexact(const double *p0, const double *p1, const double *p2, const double *p3)
Computes the (approximate) orientation predicate in 3d.
Sign in_circle_3d_SOS(const double *p0, const double *p1, const double *p2, const double *p3)
Tests whether a 3d point is inside the circumscribed circle of a 3d triangle.
Sign in_sphere_3d_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4)
Tests whether a 3d point is inside the circumscribed sphere of a 3d tetrahedron.
Sign side4_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4, const double *q0, const double *q1, const double *q2, const double *q3, coord_index_t DIM)
Computes the side of a point (given as the intersection between a tetrahedron and three bisectors) re...
void show_stats()
Displays some statistics about predicates, including the number of calls, the number of exact arithme...
Sign orient_2d(const vec2HE &p0, const vec2HE &p1, const vec2HE &p2)
Computes the orientation predicate in 2d.
Sign SOS(COMPARE compare, const POINT &p1, FUNC1 sos_p1, const POINT &p2, FUNC2 sos_p2, const POINT &p3, FUNC3 sos_p3, const POINT &p4, FUNC4 sos_p4)
template for writing symbolic perturbation in predicates
Sign det_3d(const double *p0, const double *p1, const double *p2)
Computes the sign of the determinant of a 3x3 matrix formed by three 3d points.
Sign det_compare_4d(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4)
Computes the sign of the determinant of a 4x4 matrix formed by three 4d points and the difference of ...
Sign side4_3d(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4)
Computes the side of a point (given as the intersection between three bisectors) relative to another ...
Sign dot_3d(const double *p0, const double *p1, const double *p2)
Computes the sign of the dot product between two vectors.
bool points_are_identical_3d(const double *p1, const double *p2)
Tests whether two 3d points are identical.
SOSMode
Mode for symbolic perturbations.
bool points_are_colinear_3d(const double *p1, const double *p2, const double *p3)
Tests whether three 3d points are colinear.
Sign side2_SOS(const double *p0, const double *p1, const double *p2, const double *q0, const double *q1, coord_index_t DIM)
Computes the side of a point (given as the intersection between a segment and a bisector) relative to...
bool points_are_identical_2d(const double *p1, const double *p2)
Tests whether two 2d points are identical.
Sign side3_3dlifted_SOS(const double *p0, const double *p1, const double *p2, const double *p3, double h0, double h1, double h2, double h3, const double *q0, const double *q1, const double *q2, bool SOS=true)
Computes the side of a point (given as the intersection between a facet and two bisectors) relative t...
Sign side1_SOS(const double *p0, const double *p1, const double *q0, coord_index_t DIM)
Computes the side of a point (given directly) relative to a bisector.
void initialize()
Needs to be called before using any predicate.
void terminate()
Needs to be called at the end of the program.
bool aligned_3d(const vec3HE &p0, const vec3HE &p1, const vec3HE &p2)
Tests whether three 3d points are aligned.
Sign orient_3d(const vec3HE &p0, const vec3HE &p1, const vec3HE &p2, const vec3HE &p3)
Computes the orientation predicate in 3d.
SOSMode get_SOS_mode()
Gets the current mode for handling symbolic perturbations.
void set_SOS_mode(SOSMode m)
Sets the current mode for handling symbolic perturbations (SOS for Simulation Of Simplicity).
bool permutation_is_odd(const T **orig, const T **perm, index_t n)
Computes the parity of a permutation.
Global Vorpaline namespace.
T det3x3(const T &a11, const T &a12, const T &a13, const T &a21, const T &a22, const T &a23, const T &a31, const T &a32, const T &a33)
Computes a three-by-three determinant.
Sign geo_sgn(const T &x)
Gets the sign of a value.
geo_index_t index_t
The type for storing and manipulating indices.
Sign orient_3d_SOS_impl(const T &p0, const T &p1, const T &p2, const T &p3)
Implementation of the perturbed orient_3d predicate.
Sign
Integer constants that represent the sign of a value.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Types and functions for numbers manipulation.