Mercurial > repos > public > sbplib_julia
changeset 2013:7895b509f9bf feature/grids/geometry_functions
Implement Grids.jacobian for Arc
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 07 May 2025 15:25:25 +0200 |
parents | 4617e4b74b82 |
children | 6478c29effce |
files | src/Grids/geometry.jl test/Grids/geometry_test.jl |
diffstat | 2 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/geometry.jl Wed May 07 08:39:06 2025 +0200 +++ b/src/Grids/geometry.jl Wed May 07 15:25:25 2025 +0200 @@ -177,8 +177,9 @@ return A.c((1-t)*θ₀ + t*θ₁) end -function Grids.jacobian(a::Arc, t) - return nothing +function Grids.jacobian(A::Arc, t) + (;c, θ₀, θ₁) = A + return (θ₁-θ₀)*jacobian(c, t) end
--- a/test/Grids/geometry_test.jl Wed May 07 08:39:06 2025 +0200 +++ b/test/Grids/geometry_test.jl Wed May 07 15:25:25 2025 +0200 @@ -177,7 +177,28 @@ @test a(1) ≈ [0,1] @testset "Grids.jacobian" begin - @test_broken false + c = Circle([0,0], 1) + + @testset "Matched to circle" begin + a = Arc(c, 0, 1) + @testset for t ∈ range(0,1,8) + @test jacobian(a,t) ≈ jacobian(c,t) + end + end + + @testset "Full circle" begin + a = Arc(c, 0, 2π) + @testset for t ∈ range(0,1,8) + @test jacobian(a,t) ≈ 2π*jacobian(c,t) + end + end + + @testset "Other" begin + a = Arc(c, π/3, 5π/4) + @testset for t ∈ range(0,1,8) + @test jacobian(a,t) ≈ 11π/12*jacobian(c,t) + end + end end end