Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Commit 4f1ba71

Browse files
authored
Merge pull request #166 from JuliaGeometry/sd-refactor
add Polygons + do long standing refactors
2 parents 7ba690c + 510e910 commit 4f1ba71

26 files changed

+914
-625
lines changed

src/GeometryTypes.jl

+19-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ using StaticArrays
44
using ColorTypes
55
using LinearAlgebra
66

7-
import FixedPointNumbers # U8
7+
import FixedPointNumbers
8+
using FixedPointNumbers: N0f8
89

910
import Base: ==,
1011
*,
@@ -25,43 +26,34 @@ import Base: ==,
2526
size,
2627
split,
2728
union,
28-
unique
29+
unique,
30+
iterate,
31+
eltype
2932

3033
include("FixedSizeArrays.jl")
3134
using .FixedSizeArrays
3235

3336
include("types.jl")
34-
include("typeutils.jl")
37+
include("utils.jl")
3538
include("typealias.jl")
36-
include("baseutils.jl")
37-
include("linalgutils.jl")
3839
include("simplices.jl")
39-
include("algorithms.jl")
4040
include("faces.jl")
4141
include("hyperrectangles.jl")
4242
include("hypersphere.jl")
4343
include("hypercube.jl")
44-
include("relations.jl")
45-
include("operations.jl")
4644
include("meshes.jl")
47-
include("primitives.jl")
4845
include("distancefields.jl")
49-
include("setops.jl")
50-
include("display.jl")
51-
include("slice.jl")
5246
include("decompose.jl")
53-
include("deprecated.jl")
54-
include("center.jl")
5547
include("convexhulls.jl")
5648
include("gjk.jl")
57-
include("polygons.jl")
49+
include("polygon.jl")
50+
include("polygon_triangulations.jl")
5851
include("lines.jl")
5952
include("cylinder.jl")
6053

6154
export AABB,
6255
AbstractFlexibleGeometry,
6356
AbstractGeometry,
64-
AbsoluteRectangle,
6557
AbstractMesh,
6658
AbstractSimplex,
6759
AbstractDistanceField,
@@ -100,6 +92,7 @@ export AABB,
10092
HyperCube,
10193
HyperSphere,
10294
intersects,
95+
isinside,
10396
LineSegment,
10497
Mat,
10598
Mesh2D,
@@ -190,6 +183,15 @@ export AABB,
190183
OffsetInteger,
191184
ZeroIndex,
192185
OneIndex,
193-
GLIndex
186+
GLIndex,
187+
Rect,
188+
Rect2D,
189+
Rect3D,
190+
IRect,
191+
IRect2D,
192+
IRect3D,
193+
FRect,
194+
FRect2D,
195+
FRect3D
194196

195197
end # module

src/algorithms.jl

-193
This file was deleted.

src/center.jl

-10
This file was deleted.

src/convexhulls.jl

+13
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,16 @@ Base.convert(::Type{F}, c::HyperCube) where {F <: AFG} = F(c)
7171
function Base.isapprox(s1::AbstractConvexHull, s2::AbstractConvexHull;kw...)
7272
isapprox(vertexmat(s1), vertexmat(s2); kw...)
7373
end
74+
75+
76+
# could add an @symmetric macro, which defines min_euclidean(pt, s) from
77+
# min_euclidean(s, pt) automatically etc.
78+
@inline min_euclidean(pt1::Vec, pt2::Vec) = norm(pt1-pt2)
79+
min_euclidean(pt::Vec, s::Simplex) = (sqdist(pt, s))
80+
min_euclidean(s::Simplex, pt::Vec) = min_euclidean(pt, s)
81+
min_euclidean(r1::HyperRectangle, r2::Vec) = sqrt(min_euclideansq(r1, r2))
82+
min_euclidean(r1::Vec, r2::HyperRectangle) = sqrt(min_euclideansq(r1, r2))
83+
min_euclidean(r1::HyperRectangle, r2::HyperRectangle) = sqrt(min_euclideansq(r1, r2))
84+
min_euclidean(c1::AbstractConvexHull, pt::Vec) = gjk(c1,pt)
85+
min_euclidean(pt::Vec, c2::AbstractConvexHull) = gjk(pt,c2)
86+
min_euclidean(c1::AbstractConvexHull, c2::AbstractConvexHull) = gjk(c1,c2)

src/decompose.jl

+1
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ function decompose(::Type{FT}, c::Cylinder{2}, resolution = (2, 2)) where FT <:
428428
r = SimpleRectangle(c.origin[1] - c.r/2, c.origin[2], c.r, height(c))
429429
return decompose(FT, r, resolution)
430430
end
431+
431432
function decompose(::Type{FT}, c::Cylinder{3}, facets = 30) where FT <: Face
432433
isodd(facets) ? facets = 2 * div(facets, 2) : nothing
433434
facets < 8 ? facets = 8 : nothing; nbv = Int(facets / 2)

src/deprecated.jl

Whitespace-only changes.

src/display.jl

-9
This file was deleted.

src/hypercube.jl

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ width(prim::HyperCube) = prim.width
33
widths(prim::HyperCube{N,T}) where {N,T} = Vec{N,T}(prim.width)
44
maximum(prim::HyperCube{N,T}) where {N,T} = origin(prim)+widths(prim)
55
minimum(prim::HyperCube{N,T}) where {N,T} = origin(prim)
6+
centered(C::Type{HyperCube{N,T}}) where {N,T} = C(Vec{N,T}(-0.5), T(1))
7+
function centered(::Type{T}) where T <: HyperCube
8+
centered(HyperCube{ndims_or(T, 3), eltype_or(T, Float32)})
9+
end

0 commit comments

Comments
 (0)