696696 @test all (getindex .(Ref (mp), 1 : 10 ) .== ps1)
697697 @test size (mp) == (10 , ) # TODO : Does this make sense?
698698 @test length (mp) == 10
699+ end
700+
701+ @testset " Cone" begin
702+ @testset " constructors" begin
703+ v1 = rand (Point{3 ,Float64})
704+ v2 = rand (Point{3 ,Float64})
705+ R = rand ()
706+ s = Cone (v1, v2, R)
707+ @test typeof (s) == Cone{Float64}
708+ @test origin (s) == v1
709+ @test extremity (s) == v2
710+ @test radius (s) == R
711+ @test height (s) == norm (v2 - v1)
712+ @test isapprox (direction (s), (v2 - v1) ./ norm (v2 .- v1))
713+ end
714+
715+ @testset " decompose" begin
716+ v1 = Point {3,Float64} (1 , 2 , 3 )
717+ v2 = Point {3,Float64} (4 , 5 , 6 )
718+ R = 5.0
719+ s = Cone (v1, v2, R)
720+ positions = Point{3 ,Float64}[
721+ (4.535533905932738 , - 1.5355339059327373 , 3.0 ),
722+ (3.0412414523193148 , 4.041241452319315 , - 1.0824829046386295 ),
723+ (- 2.535533905932737 , 5.535533905932738 , 2.9999999999999996 ),
724+ (- 1.0412414523193152 , - 0.04124145231931431 , 7.0824829046386295 ),
725+ (4 , 5 , 6 ),
726+ (1 , 2 , 3 )
727+ ]
728+
729+ @test decompose (Point3{Float64}, Tessellation (s, 8 )) ≈ positions
730+
731+ _faces = TriangleFace[
732+ (1 ,2 ,5 ), (2 ,3 ,5 ), (3 ,4 ,5 ), (4 ,1 ,5 ),
733+ (1 ,2 ,6 ), (2 ,3 ,6 ), (3 ,4 ,6 ), (4 ,1 ,6 )]
734+
735+ @test _faces == decompose (TriangleFace{Int}, Tessellation (s, 8 ))
736+
737+ m = triangle_mesh (Tessellation (s, 8 ))
738+ @test m === triangle_mesh (m)
739+ @test GeometryBasics. faces (m) == decompose (GLTriangleFace, _faces)
740+ @test GeometryBasics. coordinates (m) ≈ positions
741+
742+ m = normal_mesh (s) # just test that it works without explicit resolution parameter
743+ @test hasproperty (m, :position )
744+ @test hasproperty (m, :normal )
745+ @test faces (m) isa AbstractVector{GLTriangleFace}
746+
747+ ns = Vec{3 , Float32}[
748+ (0.90984505 , - 0.10920427 , 0.40032038 ),
749+ (0.6944946 , 0.6944946 , - 0.18802801 ),
750+ (- 0.10920427 , 0.90984505 , 0.40032038 ),
751+ (0.106146194 , 0.106146194 , 0.9886688 ),
752+ (0.0 , 0.0 , 0.0 ),
753+ (- 0.57735026 , - 0.57735026 , - 0.57735026 ),
754+ ]
755+
756+ @test ns == decompose_normals (Tessellation (s, 8 ))
757+
758+ muv = uv_mesh (s)
759+ @test ! hasproperty (muv, :uv ) # not defined yet
760+ end
699761end
0 commit comments