changeset 1974:3ed7ca1f60c4 feature/grids/geometry_functions

Implement Grids.jacobian for Line
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 25 Feb 2025 22:39:28 +0100
parents 8e9575b518a1
children 79adad4a15d6
files src/Grids/geometry.jl test/Grids/geometry_test.jl
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/Grids/geometry.jl	Fri Feb 14 22:19:06 2025 +0100
+++ b/src/Grids/geometry.jl	Tue Feb 25 22:39:28 2025 +0100
@@ -15,6 +15,7 @@
 
 (c::Line)(s) = c.p + s*c.tangent
 
+Grids.jacobian(l::Line, t) = l.tangent
 
 struct LineSegment{PT}
     a::PT
--- a/test/Grids/geometry_test.jl	Fri Feb 14 22:19:06 2025 +0100
+++ b/test/Grids/geometry_test.jl	Tue Feb 25 22:39:28 2025 +0100
@@ -21,6 +21,14 @@
         @test l(1) == [1,2] + [2,3]
         @test l(1/2) == [1,2] + [2,3]/2
     end
+
+    @testset "Grids.jacobian" begin
+        l = Line([1,2],[2,3])
+
+        @test Grids.jacobian(l,0) == [2,3]
+        @test Grids.jacobian(l,1) == [2,3]
+        @test Grids.jacobian(l,1/2) == [2,3]
+    end
 end
 
 @testset "LineSegment" begin