From 2be3e09b31836cf380bf32ed6b7439169d8518be Mon Sep 17 00:00:00 2001 From: schillic Date: Tue, 23 Jul 2024 09:09:18 +0200 Subject: [PATCH] make 'rand' of Tetrahedron consistent --- src/Sets/Tetrahedron/TetrahedronModule.jl | 1 + src/Sets/Tetrahedron/rand.jl | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Sets/Tetrahedron/TetrahedronModule.jl b/src/Sets/Tetrahedron/TetrahedronModule.jl index a40701dce3..630e665f8b 100644 --- a/src/Sets/Tetrahedron/TetrahedronModule.jl +++ b/src/Sets/Tetrahedron/TetrahedronModule.jl @@ -6,6 +6,7 @@ using ..LazySets: AbstractPolytope using LinearAlgebra: dot, cross using Random: AbstractRNG, GLOBAL_RNG using ReachabilityBase.Comparison: isapproxzero +using ReachabilityBase.Distribution: reseed! using ReachabilityBase.Require: require @reexport import ..API: constraints_list, dim, isoperationtype, rand, ∈, σ diff --git a/src/Sets/Tetrahedron/rand.jl b/src/Sets/Tetrahedron/rand.jl index 1749b2ead8..bc79db057b 100644 --- a/src/Sets/Tetrahedron/rand.jl +++ b/src/Sets/Tetrahedron/rand.jl @@ -1,8 +1,9 @@ -function rand(::Type{Tetrahedron}; N::Type{<:Real}=Float64, rng::AbstractRNG=GLOBAL_RNG, - seed::Union{Int,Nothing}=nothing) +function rand(::Type{Tetrahedron}; N::Type{<:Real}=Float64, dim::Int=3, + rng::AbstractRNG=GLOBAL_RNG, seed::Union{Int,Nothing}=nothing) + @assert dim == 3 "cannot create a random Tetrahedron of dimension $dim" require(@__MODULE__, :LazySets; fun_name="rand") + rng = reseed!(rng, seed) P = rand(VPolytope; N=N, dim=3, rng=rng, seed=seed, num_vertices=4) - vertices = P.vertices - return Tetrahedron(vertices) + return Tetrahedron(P.vertices) end