Skip to content

Commit 003022b

Browse files
committed
Convert the orient predicate to AdaptivePredicates
https://github.com/JuliaGeometry/AdaptivePredicates.jl is a library that implements adaptive predicates - substantially faster, BUT harder to construct, than exact predicates. Adaptive predicates are valid through the range of coordinates that geometries usually have, but we may need exact predicates if they are not.
1 parent 1f2502b commit 003022b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ authors = ["Anshul Singhvi <anshulsinghvi@gmail.com>", "Rafael Schouten <rafaels
44
version = "0.1.16"
55

66
[deps]
7+
AdaptivePredicates = "35492f91-a3bd-45ad-95db-fcad7dcfedb7"
78
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
89
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
910
DelaunayTriangulation = "927a84f5-c5f4-47a5-9785-b46e178433df"
@@ -31,6 +32,7 @@ GeometryOpsProjExt = "Proj"
3132
GeometryOpsTGGeometryExt = "TGGeometry"
3233

3334
[compat]
35+
AdaptivePredicates = "1.2"
3436
CoordinateTransformations = "0.5, 0.6"
3537
DataAPI = "1"
3638
DelaunayTriangulation = "1.0.4"

src/methods/clipping/predicates.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ module Predicates
44
import ExactPredicates.Codegen: group!, @genpredicate
55
import GeometryOps: False, True, booltype, _tuple_point
66
import GeoInterface as GI
7+
import AdaptivePredicates
78

89
#= Determine the orientation of c with regards to the oriented segment (a, b).
910
Return 1 if c is to the left of (a, b).
1011
Return -1 if c is to the right of (a, b).
1112
Return 0 if c is on (a, b) or if a == b. =#
12-
orient(a, b, c; exact) = _orient(booltype(exact), a, b, c)
13+
orient(a, b, c; exact) = _orient(booltype(exact), _tuple_point(a, Float64), _tuple_point(b, Float64), _tuple_point(c, Float64))
1314

1415
# If `exact` is `true`, use `ExactPredicates` to calculate the orientation.
15-
_orient(::True, a, b, c) = ExactPredicates.orient(_tuple_point(a, Float64), _tuple_point(b, Float64), _tuple_point(c, Float64))
16+
_orient(::True, a, b, c) = AdaptivePredicates.orient2p(_tuple_point(a, Float64), _tuple_point(b, Float64), _tuple_point(c, Float64))
17+
# _orient(::True, a, b, c) = ExactPredicates.orient(_tuple_point(a, Float64), _tuple_point(b, Float64), _tuple_point(c, Float64))
1618
# If `exact` is `false`, calculate the orientation without using `ExactPredicates`.
1719
function _orient(exact::False, a, b, c)
1820
a = a .- c

0 commit comments

Comments
 (0)