Skip to content

Commit 26f5388

Browse files
authored
Merge branch 'master' into sd/simple-mesh
2 parents 4ec151a + 138fd1c commit 26f5388

File tree

14 files changed

+308
-87
lines changed

14 files changed

+308
-87
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [SimonDanisch]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: simon-danisch
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/RegisterAction.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
version:
66
description: Version to register or component to bump
77
required: true
8-
98
jobs:
109
register:
1110
runs-on: ubuntu-latest

Project.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GeometryBasics"
22
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
33
authors = ["SimonDanisch <[email protected]>"]
4-
version = "0.4.9"
4+
version = "0.4.11"
55

66
[deps]
77
EarCut_jll = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
@@ -12,10 +12,15 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1313

1414
[compat]
15+
Aqua = "0.8"
1516
EarCut_jll = "2"
1617
Extents = "0.1"
1718
GeoInterface = "1.0.1"
19+
GeoJSON = "0.7, 0.8"
1820
IterTools = "1.3.0"
21+
LinearAlgebra = "<0.0.1,1"
22+
OffsetArrays = "1"
23+
Random = "<0.0.1,1"
1924
julia = "1.6"
2025

2126
[extras]

docs/src/index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,40 @@ Use `GeometryBasics.mesh` to get a mesh directly from a geometry:
106106
```@repl quickstart
107107
mesh = GeometryBasics.mesh(rect)
108108
```
109+
110+
111+
## Aliases
112+
113+
GeometryBasics exports common aliases for Point, Vec, Mat and Rect:
114+
115+
### Vec
116+
117+
| |`T`(eltype) |`Float64` |`Float32` |`Int` |`UInt` |
118+
|--------|------------|----------|----------|----------|----------|
119+
|`N`(dim)|`Vec{N,T}` |`Vecd{N}` |`Vecf{N}` |`Veci{N}` |`Vecui{N}`|
120+
|`2` |`Vec2{T}` |`Vec2d` |`Vec2f` |`Vec2i` |`Vec2ui` |
121+
|`3` |`Vec3{T}` |`Vec3d` |`Vec3f` |`Vec3i` |`Vec3ui` |
122+
123+
### Point
124+
125+
| |`T`(eltype) |`Float64` |`Float32` |`Int` |`UInt` |
126+
|--------|------------|----------|----------|----------|----------|
127+
|`N`(dim)|`Point{N,T}`|`Pointd{N}`|`Pointf{N}`|`Pointi{N}`|`Pointui{N}`|
128+
|`2` |`Point2{T}` |`Point2d` |`Point2f` |`Point2i` |`Point2ui`|
129+
|`3` |`Point3{T}` |`Point3d` |`Point3f` |`Point3i` |`Point3ui`|
130+
131+
### Mat
132+
133+
| |`T`(eltype) |`Float64` |`Float32` |`Int` |`UInt` |
134+
|--------|------------|----------|----------|----------|----------|
135+
|`N`(dim)|`Mat{N,T}` |`Matd{N}` |`Matf{N}` |`Mati{N}` |`Matui{N}`|
136+
|`2` |`Mat2{T}` |`Mat2d` |`Mat2f` |`Mat2i` |`Mat2ui` |
137+
|`3` |`Mat3{T}` |`Mat3d` |`Mat3f` |`Mat3i` |`Mat3ui` |
138+
139+
### Rect
140+
141+
| |`T`(eltype) |`Float64` |`Float32` |`Int` |`UInt` |
142+
|--------|------------|----------|----------|----------|----------|
143+
|`N`(dim)|`Rect{N,T}` |`Rectd{N}`|`Rectf{N}`|`Recti{N}`|`Rectui{N}`|
144+
|`2` |`Rect2{T}` |`Rect2d` |`Rect2f` |`Rect2i` |`Rect2ui` |
145+
|`3` |`Rect3{T}` |`Rect3d` |`Rect3f` |`Rect3i` |`Rect3ui` |

docs/src/meshes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ The following functions can be called on an [`AbstractMesh`](@ref) to access its
1919

2020
* [`faces`](@ref)
2121
* [`coordinates`](@ref)
22-
* [`texturecoordinates`](@ref)
22+
* `texturecoordinates`
2323
* [`normals`](@ref)
2424

src/GeometryBasics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export uv_mesh, normal_mesh, uv_normal_mesh
5757
export height, origin, radius, width, widths
5858
export HyperSphere, Circle, Sphere
5959
export Cylinder, Cylinder2, Cylinder3, Pyramid, extremity
60-
export HyperRectangle, Rect, Rect2, Rect3, Recti, Rect2i, Rect3i, Rectf, Rect2f, Rect3f
60+
export HyperRectangle, Rect, Rect2, Rect3, Recti, Rect2i, Rect3i, Rectf, Rect2f, Rect3f, Rectd, Rect2d, Rect3d
6161
export before, during, meets, overlaps, intersects, finishes
6262
export centered, direction, area, volume, update
6363
export max_dist_dim, max_euclidean, max_euclideansq, min_dist_dim, min_euclidean

src/basic_types.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ end
2727
return map(i-> elements[i], face.data)
2828
end
2929

30-
@fixed_vector SimplexFace AbstractSimplexFace
30+
@fixed_vector SimplexFace = AbstractSimplexFace
3131

3232
const TetrahedronFace{T} = SimplexFace{4,T}
3333
Face(::Type{<:SimplexFace{N}}, ::Type{T}) where {N,T} = SimplexFace{N,T}
3434

35-
@fixed_vector NgonFace AbstractNgonFace
35+
"""
36+
Face index, connecting points to form an Ngon
37+
"""
38+
39+
@fixed_vector NgonFace = AbstractNgonFace
40+
3641

3742
const LineFace{T} = NgonFace{2,T}
3843
const TriangleFace{T} = NgonFace{3,T}

src/fixed_arrays.jl

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import Base: setindex
66
abstract type StaticVector{N, T} end
77
function similar_type end
88

9-
macro fixed_vector(VecT, SuperT)
9+
macro fixed_vector(name_parent)
10+
@assert name_parent.head == :(=)
11+
name, parent = name_parent.args
12+
1013
expr = quote
1114
struct $(VecT){N, T} <: $(SuperT){N, T}
1215
data::NTuple{N,T}
@@ -186,8 +189,9 @@ Base.reverse(x::P) where P <: StaticVector = P(reverse(x.data))
186189
# Since we don't inherit from AbstractArray, some extra functions need to be overloaded
187190
LinearAlgebra.promote_leaf_eltypes(x::StaticVector{N, T}) where {N,T} = T
188191

189-
@fixed_vector Point StaticVector
190-
@fixed_vector Vec StaticVector
192+
@fixed_vector Point = StaticVector
193+
@fixed_vector Vec = StaticVector
194+
191195

192196
Base.lastindex(::StaticVector{N}) where N = N
193197

@@ -199,31 +203,36 @@ const VecTypes{N,T} = Union{StaticVector{N,T}, NTuple{N,T}}
199203
const Vecf{N} = Vec{N, Float32}
200204
const PointT{T} = Point{N,T} where N
201205
const Pointf{N} = Point{N,Float32}
202-
Base.isnan(p::Union{Point,Vec}) = any(x -> isnan(x), p)
203-
204-
include("mat.jl")
205-
206-
for i in 1:4
207-
for T in [:Point, :Vec]
208-
name = Symbol("$T$i")
209-
namef = Symbol("$T$(i)f")
210-
@eval begin
211-
const $name = $T{$i}
212-
const $namef = $T{$i,Float32}
213-
export $name
214-
export $namef
206+
207+
Base.isnan(p::Union{AbstractPoint,Vec}) = any(isnan, p)
208+
Base.isinf(p::Union{AbstractPoint,Vec}) = any(isinf, p)
209+
Base.isfinite(p::Union{AbstractPoint,Vec}) = all(isfinite, p)
210+
211+
## Generate aliases
212+
## As a text file instead of eval/macro, to not confuse code linter
213+
214+
#=
215+
open(joinpath(@__DIR__, "generated-aliases.jl"), "w") do io
216+
for i in 1:4
217+
for T in [:Point, :Vec, :Mat]
218+
namei = "$T$i"
219+
res = T == :Mat ? "Mat{$i,$i,T,$(i * i)}" : "$T{$i,T}"
220+
println(io, "const $(namei){T} = $res")
221+
println(io, "export $namei")
222+
for (postfix, t) in ["d" => Float64, "f" => Float32, "i" => Int, "ui" => UInt]
223+
namep = "$T$i$postfix"
224+
println(io, "const $(namep) = $(namei){$t}")
225+
println(io, "export $namep")
226+
# mnamep = "$(mname)$postfix"
227+
# println(io, "const $mnamep = $mname{$t}")
228+
# println(io, "export $mnamep")
229+
end
215230
end
216231
end
217-
name = Symbol("Mat$i")
218-
namef = Symbol("Mat$(i)f")
219-
namef = Symbol("Mat$(i)f")
220-
@eval begin
221-
const $name{T} = $Mat{$i,$i,T, $(i*i)}
222-
const $namef = $name{Float32}
223-
export $name
224-
export $namef
225-
end
226232
end
233+
=#
234+
235+
include("generated-aliases.jl")
227236

228237
export Mat, Vec, Point, unit
229238
export Vecf, Pointf

src/generated-aliases.jl

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
const Point1{T} = Point{1,T}
2+
export Point1
3+
const Point1d = Point1{Float64}
4+
export Point1d
5+
const Point1f = Point1{Float32}
6+
export Point1f
7+
const Point1i = Point1{Int64}
8+
export Point1i
9+
const Point1ui = Point1{UInt64}
10+
export Point1ui
11+
const Vec1{T} = Vec{1,T}
12+
export Vec1
13+
const Vec1d = Vec1{Float64}
14+
export Vec1d
15+
const Vec1f = Vec1{Float32}
16+
export Vec1f
17+
const Vec1i = Vec1{Int64}
18+
export Vec1i
19+
const Vec1ui = Vec1{UInt64}
20+
export Vec1ui
21+
const Mat1{T} = Mat{1,1,T,1}
22+
export Mat1
23+
const Mat1d = Mat1{Float64}
24+
export Mat1d
25+
const Mat1f = Mat1{Float32}
26+
export Mat1f
27+
const Mat1i = Mat1{Int64}
28+
export Mat1i
29+
const Mat1ui = Mat1{UInt64}
30+
export Mat1ui
31+
const Point2{T} = Point{2,T}
32+
export Point2
33+
const Point2d = Point2{Float64}
34+
export Point2d
35+
const Point2f = Point2{Float32}
36+
export Point2f
37+
const Point2i = Point2{Int64}
38+
export Point2i
39+
const Point2ui = Point2{UInt64}
40+
export Point2ui
41+
const Vec2{T} = Vec{2,T}
42+
export Vec2
43+
const Vec2d = Vec2{Float64}
44+
export Vec2d
45+
const Vec2f = Vec2{Float32}
46+
export Vec2f
47+
const Vec2i = Vec2{Int64}
48+
export Vec2i
49+
const Vec2ui = Vec2{UInt64}
50+
export Vec2ui
51+
const Mat2{T} = Mat{2,2,T,4}
52+
export Mat2
53+
const Mat2d = Mat2{Float64}
54+
export Mat2d
55+
const Mat2f = Mat2{Float32}
56+
export Mat2f
57+
const Mat2i = Mat2{Int64}
58+
export Mat2i
59+
const Mat2ui = Mat2{UInt64}
60+
export Mat2ui
61+
const Point3{T} = Point{3,T}
62+
export Point3
63+
const Point3d = Point3{Float64}
64+
export Point3d
65+
const Point3f = Point3{Float32}
66+
export Point3f
67+
const Point3i = Point3{Int64}
68+
export Point3i
69+
const Point3ui = Point3{UInt64}
70+
export Point3ui
71+
const Vec3{T} = Vec{3,T}
72+
export Vec3
73+
const Vec3d = Vec3{Float64}
74+
export Vec3d
75+
const Vec3f = Vec3{Float32}
76+
export Vec3f
77+
const Vec3i = Vec3{Int64}
78+
export Vec3i
79+
const Vec3ui = Vec3{UInt64}
80+
export Vec3ui
81+
const Mat3{T} = Mat{3,3,T,9}
82+
export Mat3
83+
const Mat3d = Mat3{Float64}
84+
export Mat3d
85+
const Mat3f = Mat3{Float32}
86+
export Mat3f
87+
const Mat3i = Mat3{Int64}
88+
export Mat3i
89+
const Mat3ui = Mat3{UInt64}
90+
export Mat3ui
91+
const Point4{T} = Point{4,T}
92+
export Point4
93+
const Point4d = Point4{Float64}
94+
export Point4d
95+
const Point4f = Point4{Float32}
96+
export Point4f
97+
const Point4i = Point4{Int64}
98+
export Point4i
99+
const Point4ui = Point4{UInt64}
100+
export Point4ui
101+
const Vec4{T} = Vec{4,T}
102+
export Vec4
103+
const Vec4d = Vec4{Float64}
104+
export Vec4d
105+
const Vec4f = Vec4{Float32}
106+
export Vec4f
107+
const Vec4i = Vec4{Int64}
108+
export Vec4i
109+
const Vec4ui = Vec4{UInt64}
110+
export Vec4ui
111+
const Mat4{T} = Mat{4,4,T,16}
112+
export Mat4
113+
const Mat4d = Mat4{Float64}
114+
export Mat4d
115+
const Mat4f = Mat4{Float32}
116+
export Mat4f
117+
const Mat4i = Mat4{Int64}
118+
export Mat4i
119+
const Mat4ui = Mat4{UInt64}
120+
export Mat4ui

0 commit comments

Comments
 (0)