mirror of
https://gitlab.com/MisterBiggs/stl-process.git
synced 2025-08-03 12:01:33 +00:00
41 lines
1.0 KiB
Julia
41 lines
1.0 KiB
Julia
using Test
|
|
|
|
using stlProcess
|
|
|
|
using FileIO
|
|
using MeshIO
|
|
|
|
using LinearAlgebra
|
|
|
|
@testset "simple cube stl" begin
|
|
"""
|
|
inertia math:
|
|
https://hepweb.ucsd.edu/ph110b/110b_notes/node26.html
|
|
|
|
Cube is a standard cube with a length of 2 for each side.
|
|
"""
|
|
cube_path = raw"test_assets\cubeblender.stl"
|
|
stl = load(cube_path)
|
|
|
|
@testset "get_mass_properties function" begin
|
|
props = get_mass_properties(stl)
|
|
|
|
@test props.volume == 8.0
|
|
@test all(props.center_of_gravity .== 0.0)
|
|
@test all(eigvals(props.inertia) .≈ (5.0 + 1 / 3))
|
|
|
|
@testset "get_volume function" begin
|
|
@test get_volume(stl; scale=1) ≈ props.volume rtol = 0.01
|
|
@test get_volume(stl; scale=4) ≈ (4 * 2)^3 rtol = 0.01
|
|
end
|
|
end
|
|
@testset "Compare volumes with scaling" begin
|
|
for scale in 1:5
|
|
props = get_mass_properties(stl; scale=scale)
|
|
volume = get_volume(stl; scale=scale)
|
|
|
|
@test props.volume ≈ volume rtol = 0.01
|
|
end
|
|
end
|
|
end
|