Skip to content

Commit b000a4a

Browse files
authored
Merge pull request ivanfratric#57 from grimaldini/master
enables optional custom floating point type and sqrt function
2 parents 0b20851 + e6dc686 commit b000a4a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/polypartition.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ TPPLPartition::PartitionVertex::PartitionVertex() :
118118

119119
TPPLPoint TPPLPartition::Normalize(const TPPLPoint &p) {
120120
TPPLPoint r;
121-
tppl_float n = sqrt(p.x * p.x + p.y * p.y);
121+
tppl_float n = tppl_sqrt(p.x * p.x + p.y * p.y);
122122
if (n != 0) {
123123
r = p / n;
124124
} else {
@@ -132,7 +132,7 @@ tppl_float TPPLPartition::Distance(const TPPLPoint &p1, const TPPLPoint &p2) {
132132
tppl_float dx, dy;
133133
dx = p2.x - p1.x;
134134
dy = p2.y - p1.y;
135-
return (sqrt(dx * dx + dy * dy));
135+
return (tppl_sqrt(dx * dx + dy * dy));
136136
}
137137

138138
// Checks if two lines intersect.

src/polypartition.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
#include <list>
2828
#include <set>
2929

30-
typedef double tppl_float;
30+
#ifndef tppl_float
31+
#define tppl_float double
32+
#endif
33+
#ifndef tppl_sqrt
34+
#define tppl_sqrt sqrt
35+
#endif
3136

3237
enum TPPLOrientation {
3338
TPPL_ORIENTATION_CW = -1,

0 commit comments

Comments
 (0)