Skip to content

Commit

Permalink
Merge pull request #3659 from JuliaReach/schillic/tetrahedron
Browse files Browse the repository at this point in the history
Check dimensionality in `Tetrahedron` constructor
  • Loading branch information
schillic authored Dec 6, 2024
2 parents 9595b07 + 12cc7bd commit 581d639
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Sets/Tetrahedron/Tetrahedron.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Tetrahedron{N, VN<:AbstractVector{N}, VT<:AbstractVector{VN}} <: AbstractPolytope{N}
Type that represents a tetrahedron in vertex representation.
Type that represents a (3-dimensional) tetrahedron in vertex representation.
### Fields
Expand Down Expand Up @@ -35,6 +35,7 @@ struct Tetrahedron{N,VN<:AbstractVector{N},VT<:AbstractVector{VN}} <: AbstractPo

function Tetrahedron(vertices::VT) where {N,VN<:AbstractVector{N},VT<:AbstractVector{VN}}
@assert length(vertices) == 4 "a tetrahedron requires four vertices"
@assert all(v -> length(v) == 3, vertices) "a tetrahedron requires 3D vertices"
return new{N,VN,VT}(vertices)
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/Sets/Tetrahedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ for N in [Float64, Float32, Rational{Int}]
T = Tetrahedron(vertices)
@test eltype(T) == N
@test dim(T) == 3
@test_throws AssertionError Tetrahedron([vertices[1]])
@test_throws AssertionError Tetrahedron([N[1], N[2], N[3], N[4]])

vmat = reduce(hcat, vertices)
Tmat = Tetrahedron(vmat)
Expand Down

0 comments on commit 581d639

Please sign in to comment.