Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 src/Meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export
angles,
innerangles,
normal,
base,
≗,

# multi-geometries
Expand Down
7 changes: 6 additions & 1 deletion src/geometries/polytopes/pyramid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ A pyramid with points `p1`, `p2`, `p3`, `p4`, `p5`.

nvertices(::Type{<:Pyramid}) = 5

function base(p::Pyramid)
a, b, c, d, o = p.vertices
Quadrangle(a, b, c, d)
end

==(p₁::Pyramid, p₂::Pyramid) = p₁.vertices == p₂.vertices

Base.isapprox(p₁::Pyramid, p₂::Pyramid; atol=atol(lentype(p₁)), kwargs...) =
Expand All @@ -20,7 +25,7 @@ function (pyramid::Pyramid)(u, v, w)
if (u < 0 || u > 1) || (v < 0 || v > 1) || (w < 0 || w > 1)
throw(DomainError((u, v, w), "pyramid(u, v, w) is not defined for u, v, w outside [0, 1]³."))
end
a, b, c, d, o = vertices(pyramid)
a, b, c, d, o = p.vertices
q = Quadrangle(a, b, c, d)
s = Segment(q(u, v), o)
s(w)
Expand Down
2 changes: 2 additions & 0 deletions src/predicates/isconvex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ _isconvex(p::Polygon, ::Val{3}) = isconvex(proj2D(p))

isconvex(h::Hexahedron) = all(isconvex, boundary(h))

isconvex(p::Pyramid) = isconvex(base(p))

isconvex(m::Multi) = isapproxequal(measure(convexhull(m)), measure(m))

# --------------
Expand Down
16 changes: 16 additions & 0 deletions test/predicates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,22 @@ end
@test isconvex(h0)
@test isconvex(h1)
@test isconvex(h2)
p = Pyramid(
cart(0, 0, 0),
cart(1, 0, 0),
cart(1, 1, 0),
cart(0, 1, 0),
cart(0, 0, 1)
)
@test isconvex(p)
p = Pyramid(
cart(0, 0, 0),
cart(1, 0, 0),
cart(0.25, 0.25, 0),
cart(0, 1, 0),
cart(0, 0, 1)
)
@test !isconvex(p)
end

@testitem "issubset" setup = [Setup] begin
Expand Down
Loading