11
22using Test
33using VortexStepMethod
4- using VortexStepMethod: create_interpolations, find_circle_center_and_radius, calculate_inertia_tensor, center_to_com!, read_faces
4+ using VortexStepMethod: create_interpolations, find_circle_center_and_radius, calculate_inertia_tensor, center_to_com!, read_faces, calc_inertia_y_rotation
55using LinearAlgebra
66using Interpolations
77using Serialization
@@ -126,7 +126,7 @@ using Serialization
126126
127127 # Create info file
128128 info_path = test_obj_path[1 : end - 4 ] * " _info.bin"
129- le_interp, te_interp, area_interp = create_interpolations (vertices, z_center, r, π/ 4 )
129+ le_interp, te_interp, area_interp = create_interpolations (vertices, z_center, r, π/ 4 , I ( 3 ) )
130130 center_of_mass = center_to_com! (vertices, faces)
131131 inertia_tensor = calculate_inertia_tensor (vertices, faces, 1.0 , zeros (3 ))
132132
@@ -147,6 +147,20 @@ using Serialization
147147 @test isapprox ([le_interp[i](0.0 ) for i in 1 : 3 ], [0.0 , 0.0 , r+ z_center], atol= 0.03 )
148148 @test isapprox ([te_interp[i](0.0 ) for i in 1 : 3 ], [1.0 , 0.0 , r+ z_center], atol= 0.03 )
149149 end
150+
151+ @testset " Alignment to principal frame" begin
152+ vertices, faces = read_faces (test_obj_path)
153+ center_of_mass = center_to_com! (vertices, faces)
154+ inertia_tensor_b = calculate_inertia_tensor (vertices, faces, 1.0 , zeros (3 ))
155+ inertia_tensor_p, R_b_p = calc_inertia_y_rotation (inertia_tensor_b)
156+ for v in vertices
157+ v .= R_b_p * v
158+ end
159+ inertia_tensor_b2 = calculate_inertia_tensor (vertices, faces, 1.0 , zeros (3 ))
160+ inertia_tensor_p2, R_b_p2 = calc_inertia_y_rotation (inertia_tensor_b2)
161+ @test inertia_tensor_p ≈ inertia_tensor_p2
162+ @test R_b_p2 ≈ I (3 )
163+ end
150164
151165 @testset " RamAirWing Construction" begin
152166 wing = RamAirWing (test_obj_path, test_dat_path; remove_nan= true )
0 commit comments