Mercurial > repos > public > sbplib_julia
comparison test/Grids/geometry_test.jl @ 2012:4617e4b74b82 feature/grids/geometry_functions
Add arc() for constructing circle arcs between two points
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 07 May 2025 08:39:06 +0200 |
parents | d0b6c63c506e |
children | 7895b509f9bf |
comparison
equal
deleted
inserted
replaced
2011:d0b6c63c506e | 2012:4617e4b74b82 |
---|---|
179 @testset "Grids.jacobian" begin | 179 @testset "Grids.jacobian" begin |
180 @test_broken false | 180 @test_broken false |
181 end | 181 end |
182 end | 182 end |
183 | 183 |
184 @testset "arc" begin | |
185 a = [0,0] | |
186 b = [1,0] | |
187 A = arc(a,b,1/2) | |
188 @test A(0) ≈ a atol=1e-15 | |
189 @test A(1) ≈ b | |
190 @test A(0.5) ≈ [0.5, -0.5] | |
191 | |
192 A = arc(a,b,-1/2) | |
193 @test A(0) ≈ a atol=1e-15 | |
194 @test A(1) ≈ b | |
195 @test A(0.5) ≈ [0.5, 0.5] | |
196 | |
197 @testset "Unit arc" begin | |
198 A = arc([1,0],[0,1],1) | |
199 @test A(0) ≈ [1,0] | |
200 @test A(1) ≈ [0,1] | |
201 @testset for t ∈ range(0,1,13) | |
202 @test A(t) ≈ [cos(t*π/2), sin(t*π/2)] | |
203 end | |
204 end | |
205 | |
206 @testset "Inverted unit arc" begin | |
207 A = arc([1,0],[0,1],-1) | |
208 @test A(0) ≈ [1,0] | |
209 @test A(1) ≈ [0,1] | |
210 @testset "Inverted unit arc t=$t" for t ∈ range(0,1,13) | |
211 @test A(t) ≈ [1+cos(-π/2 - t*π/2), 1+sin(-π/2 - t*π/2)] | |
212 end | |
213 end | |
214 | |
215 @testset "Quarters of unit circle" begin | |
216 unitvec(θ) = [cos(θ), sin(θ)] | |
217 @testset "θ ∈ ($(i)π/4, $(i+2)π/4)" for i ∈ range(0, step=1, length=8) | |
218 θ = i*π/4 | |
219 @testset let θ₀ = θ, θ₁ = θ+π/2, r = 1 | |
220 A = arc(unitvec(θ₀), unitvec(θ₁), r) | |
221 @test A(0) ≈ unitvec(θ) | |
222 @test A(1/3) ≈ unitvec(θ+π/6) | |
223 @test A(1/2) ≈ unitvec(θ+π/4) | |
224 @test A(2/3) ≈ unitvec(θ+π/3) | |
225 @test A(1) ≈ unitvec(θ+π/2) | |
226 end | |
227 | |
228 @testset let θ₀ = θ+π/2, θ₁ = θ, r = -1 | |
229 A = arc(unitvec(θ₀), unitvec(θ₁), r) | |
230 @test A(0) ≈ unitvec(θ+π/2) | |
231 @test A(1/3) ≈ unitvec(θ+π/3) | |
232 @test A(1/2) ≈ unitvec(θ+π/4) | |
233 @test A(2/3) ≈ unitvec(θ+π/6) | |
234 @test A(1) ≈ unitvec(θ) | |
235 end | |
236 end | |
237 end | |
238 | |
239 @test_throws DomainError arc([-1,0], [1,0], 0.7) | |
240 end | |
241 | |
184 @testset "TransfiniteInterpolationSurface" begin | 242 @testset "TransfiniteInterpolationSurface" begin |
185 @testset "Constructors" begin | 243 @testset "Constructors" begin |
186 @test TransfiniteInterpolationSurface(t->[1,2], t->[2,1], t->[0,0], t->[1,1]) isa TransfiniteInterpolationSurface | 244 @test TransfiniteInterpolationSurface(t->[1,2], t->[2,1], t->[0,0], t->[1,1]) isa TransfiniteInterpolationSurface |
187 | 245 |
188 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) | 246 cs = polygon_edges([0,0],[1,0],[1,1],[0,1]) |