mirror of
https://gitlab.com/MisterBiggs/stl-process.git
synced 2025-08-03 20:11:31 +00:00
added function to find volume
This commit is contained in:
@@ -8,12 +8,25 @@ using MeshIO
|
||||
using LinearAlgebra
|
||||
|
||||
@testset "simple cube stl" begin
|
||||
# https://hepweb.ucsd.edu/ph110b/110b_notes/node26.html
|
||||
stl = load(raw"test\test_assets\cubeblender.stl")
|
||||
"""
|
||||
inertia math:
|
||||
https://hepweb.ucsd.edu/ph110b/110b_notes/node26.html
|
||||
|
||||
props = get_mass_properties(stl)
|
||||
Cube is a standard cube with a length of 2 for each side.
|
||||
"""
|
||||
cube_path = raw"test_assets\cubeblender.stl"
|
||||
stl = load(cube_path)
|
||||
|
||||
@test props.volume == 8.0
|
||||
@test all(props.center_of_gravity .== 0.0)
|
||||
@test all(eigvals(props.inertia) .≈ (5.0 + 1 / 3))
|
||||
@testset "get_mass_properties" 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" 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
|
||||
end
|
||||
|
Reference in New Issue
Block a user