Mercurial > repos > public > sbplib_julia
comparison test/Grids/geometry_test.jl @ 1969:7f4a5146c84c feature/grids/geometry_functions
Add tests and better constructor for Circle
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Fri, 14 Feb 2025 08:23:00 +0100 |
| parents | 35cb503985b6 |
| children | 8e9575b518a1 |
comparison
equal
deleted
inserted
replaced
| 1968:35cb503985b6 | 1969:7f4a5146c84c |
|---|---|
| 1 using Diffinitive.Grids | 1 using Diffinitive.Grids |
| 2 using Diffinitive.Grids: Line, LineSegment, linesegments, polygon_edges | 2 using Diffinitive.Grids: Line, LineSegment, linesegments, polygon_edges, Circle |
| 3 using StaticArrays | 3 using StaticArrays |
| 4 | 4 |
| 5 @testset "Line" begin | 5 @testset "Line" begin |
| 6 @testset "Constructors" begin | 6 @testset "Constructors" begin |
| 7 @test Line([1,2],[2,3]) isa Line{SVector{2,Int}} | 7 @test Line([1,2],[2,3]) isa Line{SVector{2,Int}} |
| 83 ] | 83 ] |
| 84 end | 84 end |
| 85 | 85 |
| 86 @testset "Circle" begin | 86 @testset "Circle" begin |
| 87 @testset "Constructors" begin | 87 @testset "Constructors" begin |
| 88 @test Circle([1,2], 1) isa Circle{SVector{2,Int},Int} | |
| 89 @test Circle([1,2], 1.) isa Circle{SVector{2,Int},Float64} | |
| 90 @test Circle([1,2.], 1.) isa Circle{SVector{2,Float64},Float64} | |
| 91 @test Circle([1,2.], 1) isa Circle{SVector{2,Float64},Int} | |
| 92 @test Circle((1,2.), 1.) isa Circle{SVector{2,Float64},Float64} | |
| 93 @test Circle((1,2), 1.) isa Circle{SVector{2,Int},Float64} | |
| 94 @test Circle((1.,2), 1) isa Circle{SVector{2,Float64},Int} | |
| 95 @test Circle((1,2), 1) isa Circle{SVector{2,Int},Int} | |
| 96 @test Circle(@SVector[1,2], 1.) isa Circle{SVector{2,Int},Float64} | |
| 97 @test Circle(@SVector[1,2.], 1.) isa Circle{SVector{2,Float64},Float64} | |
| 88 end | 98 end |
| 89 | 99 |
| 90 @test_broken false | 100 @testset "Evaluation" begin |
| 101 c = Circle([0,0], 1) | |
| 102 @test c(0) ≈ [1,0] | |
| 103 @test c(π/2) ≈ [0,1] | |
| 104 @test c(π) ≈ [-1,0] | |
| 105 @test c(3π/2) ≈ [0,-1] | |
| 106 @test c(π/4) ≈ [1/√(2),1/√(2)] | |
| 107 | |
| 108 c = Circle([0,0], 2) | |
| 109 @test c(0) ≈ [2,0] | |
| 110 @test c(π/2) ≈ [0,2] | |
| 111 @test c(π) ≈ [-2,0] | |
| 112 @test c(3π/2) ≈ [0,-2] | |
| 113 @test c(π/4) ≈ [√(2),√(2)] | |
| 114 end | |
| 91 end | 115 end |
| 92 | 116 |
| 93 @testset "TransfiniteInterpolationSurface" begin | 117 @testset "TransfiniteInterpolationSurface" begin |
| 94 @testset "Constructors" begin | 118 @testset "Constructors" begin |
| 95 end | 119 end |
