File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 11[deps ]
2+ LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
23Random = " 9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
34Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
Original file line number Diff line number Diff line change 1+ using DeformableBodies
2+ using Test
3+ using Random
4+ import LinearAlgebra: norm
5+
6+ # Uniform Distribution on Sphere
7+ function unif_sphere (m)
8+ v = randn (m)
9+ return v / norm (v)
10+ end
11+
12+ approx_zero_array (A) = all (isapprox .(A, 0.0 , atol= 1e-6 ))
13+
14+ @testset " Rigid Bodies" for i in 1 : 5
15+ @testset " Zero angular momentum" begin
16+ npts = rand (10 : 100 )
17+ # A rigid body contained on a ball
18+ r_0 = [PointMass (rand ()* 10 , unif_sphere (3 )) for i in 1 : npts]
19+ bigV_r0 = vcat (pos .(r_0)... )
20+ model = Model ( t -> r_0 # Constant trajectories
21+ , (0. , 1. )
22+ , quaternion (1 )
23+ , [0. ,0. ,0. ]
24+ )
25+ rotbodies, R, Π = solve! (model)
26+
27+ for t in range (0. , 1. , length= 30 )
28+ bigV_rt = vcat (pos .(model. inertialframe (t))... )
29+ @test R (t) ≈ 1 atol= 1e-7
30+ @test approx_zero_array (Π (t))
31+ @test isapprox (bigV_r0, bigV_rt, atol= 1e-6 )
32+ end
33+ end
34+ end
35+
Original file line number Diff line number Diff line change @@ -11,4 +11,6 @@ Random.seed!(12342352154)
1111@testset " DeformableBodies Package" begin
1212 @info " Testing Quaternions"
1313 include (filepath (" quaternions.jl" ))
14+ @info " Testing dynamics for Rigid Bodies"
15+ include (filepath (" rigid-bodies.jl" ))
1416end
You can’t perform that action at this time.
0 commit comments