Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic predicate skeleton #7

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.1.3"

[deps]
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
ExactPredicates = "429591f6-91af-11e9-00e2-59fbe8cec110"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
1 change: 1 addition & 0 deletions src/GeometryOps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include("methods/barycentric.jl")
include("methods/centroid.jl")
include("methods/distance.jl")
include("methods/equals.jl")
include("methods/clipping/predicates.jl")
include("methods/clipping/clipping_processor.jl")
include("methods/clipping/coverage.jl")
include("methods/clipping/cut.jl")
Expand Down
49 changes: 49 additions & 0 deletions src/methods/clipping/predicates.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module Predicates

using ExactPredicates
using ExactPredicates.Codegen
using ExactPredicates.Codegen: group!, coord, @genpredicate

using ExactPredicates: ext, inp

# This is the implementation of r_cross_s from 2 points in the `_intersection_points` file.
# 0 == parallel
@genpredicate function isparallel(a1 :: 2, a2 :: 2, b1 :: 2, b2 :: 2)
r = a2 - a1
s = b2 - b1
group!(r...)
group!(s...)
ext(r, s)
end
# This is the implementation of `iscollinear` from `intersection_points`.
# 0 == parallel.
@genpredicate function iscollinear(a1::2, a2::2, b1::2, b2::2)
Δqp = b1 - a1
s = b2 - b1
group!(Δqp...)
group!(s...)
ext(s, Δqp)
end

end

import .Predicates

# Predicates.r_cross_s(...)

#=
# If we want to inject adaptivity, we would do:
using MultiFloats
function isparallel_adaptive(a1, a2, b1, b2)
r = Float64x2.(a2) - Float64x2.(a1)
s = Float64x2.(b2) - Float64x2.(b1)
return sign(Predicates.ext(r, s))
end
function isparallel(a1, a2, b1, b2)
# try Predicates.isparallel_naive(a1, a2, b1, b2)
# check the error bound there
# then try isparallel_adaptive(a1, a2, b1, b2)
# then try Predicates.isparallel_slow
# then try isparallel
end
=#
Loading