From 4760e721d772b5dc9b23ab97fc29f81ec9837ef4 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Mon, 20 Jan 2025 14:26:30 -0500 Subject: [PATCH 1/5] Implement parametrization function for Frustum --- src/geometries/primitives/frustum.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/geometries/primitives/frustum.jl b/src/geometries/primitives/frustum.jl index 505c840a4..971064686 100644 --- a/src/geometries/primitives/frustum.jl +++ b/src/geometries/primitives/frustum.jl @@ -40,3 +40,12 @@ axis(f::Frustum) = axis(boundary(f)) Base.isapprox(f₁::Frustum, f₂::Frustum; atol=atol(lentype(f₁)), kwargs...) = isapprox(boundary(f₁), boundary(f₂); atol, kwargs...) + +function (frustum::Frustum)(r, φ, h) + if (r < 0 || r > 1) || (φ < 0 || φ > 1) || (h < 0 || h > 1) + throw(DomainError((r, φ, h), "frustum(r, φ, h) is not defined for r, φ, h outside [0, 1]³.")) + end + a = bottom(frustum)(r, φ) + b = top(frustum)(r, φ) + Segment(a, b)(h) +end From b935d23316ad13365ce550fc64de23b7300f64a4 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Mon, 20 Jan 2025 14:26:38 -0500 Subject: [PATCH 2/5] Add tests --- test/primitives.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/primitives.jl b/test/primitives.jl index 1ef66b29d..36275a4b5 100644 --- a/test/primitives.jl +++ b/test/primitives.jl @@ -1248,6 +1248,10 @@ end @test crs(f) <: Cartesian{NoDatum} @test Meshes.lentype(f) == ℳ @test boundary(f) == FrustumSurface(db, dt) + @test f(T(0), T(0), T(0)) == center(db) + @test norm(f(T(1), T(0), T(0)) - f(T(1), T(0), T(0))) ≈ radius(db) + @test f(T(0), T(0), T(1)) == center(dt) + @test norm(f(T(1), T(0), T(1)) - f(T(1), T(0), T(1))) ≈ radius(db) @test_throws AssertionError Frustum(db, db) From 90b58590a139bd95aa89ba12136d0c787a2a4075 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Mon, 20 Jan 2025 14:30:38 -0500 Subject: [PATCH 3/5] Fix coords --- test/primitives.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/primitives.jl b/test/primitives.jl index 36275a4b5..609b67389 100644 --- a/test/primitives.jl +++ b/test/primitives.jl @@ -1249,9 +1249,9 @@ end @test Meshes.lentype(f) == ℳ @test boundary(f) == FrustumSurface(db, dt) @test f(T(0), T(0), T(0)) == center(db) - @test norm(f(T(1), T(0), T(0)) - f(T(1), T(0), T(0))) ≈ radius(db) + @test norm(f(T(1), T(0), T(0)) - f(T(0), T(0), T(0))) ≈ radius(db) @test f(T(0), T(0), T(1)) == center(dt) - @test norm(f(T(1), T(0), T(1)) - f(T(1), T(0), T(1))) ≈ radius(db) + @test norm(f(T(1), T(0), T(1)) - f(T(0), T(0), T(1))) ≈ radius(db) @test_throws AssertionError Frustum(db, db) From cba7a2a129f5cb4f9deef1bcda12a09194da8eb6 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Mon, 20 Jan 2025 14:33:07 -0500 Subject: [PATCH 4/5] Add a test_throws --- test/primitives.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/primitives.jl b/test/primitives.jl index 609b67389..dbdaab70f 100644 --- a/test/primitives.jl +++ b/test/primitives.jl @@ -1252,6 +1252,7 @@ end @test norm(f(T(1), T(0), T(0)) - f(T(0), T(0), T(0))) ≈ radius(db) @test f(T(0), T(0), T(1)) == center(dt) @test norm(f(T(1), T(0), T(1)) - f(T(0), T(0), T(1))) ≈ radius(db) + @test_throws DomainError f(T(0), T(0), T(1.5)) @test_throws AssertionError Frustum(db, db) From 2c8d2d20ad1682f730eaab0bfbc29e07773d0563 Mon Sep 17 00:00:00 2001 From: Michael Ingold Date: Mon, 20 Jan 2025 14:51:11 -0500 Subject: [PATCH 5/5] Update name --- test/primitives.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/primitives.jl b/test/primitives.jl index dbdaab70f..42dbf20e3 100644 --- a/test/primitives.jl +++ b/test/primitives.jl @@ -1251,7 +1251,7 @@ end @test f(T(0), T(0), T(0)) == center(db) @test norm(f(T(1), T(0), T(0)) - f(T(0), T(0), T(0))) ≈ radius(db) @test f(T(0), T(0), T(1)) == center(dt) - @test norm(f(T(1), T(0), T(1)) - f(T(0), T(0), T(1))) ≈ radius(db) + @test norm(f(T(1), T(0), T(1)) - f(T(0), T(0), T(1))) ≈ radius(dt) @test_throws DomainError f(T(0), T(0), T(1.5)) @test_throws AssertionError Frustum(db, db)