1
0
mirror of https://gitlab.com/MisterBiggs/stl-process.git synced 2025-08-05 13:01:23 +00:00

add comments

This commit is contained in:
2022-04-09 12:04:07 -07:00
parent 7facc6c0aa
commit 3d52c55f09
2 changed files with 4 additions and 3 deletions

View File

@@ -76,7 +76,8 @@ function get_mass_properties(triangles; scale=1)
inertia[2, 3] = inertia[3, 2] = -(intg[9] - volume .* center_of_gravity[2] .* center_of_gravity[3]) inertia[2, 3] = inertia[3, 2] = -(intg[9] - volume .* center_of_gravity[2] .* center_of_gravity[3])
inertia[1, 3] = inertia[3, 1] = -(intg[10] - volume .* center_of_gravity[3] .* center_of_gravity[1]) inertia[1, 3] = inertia[3, 1] = -(intg[10] - volume .* center_of_gravity[3] .* center_of_gravity[1])
surface_area = norm.(eachrow([x0 y0 z0] - [x1 y1 z1]) .× eachrow([x1 y1 z1] - [x2 y2 z2])) / 2 |> sum # https://math.stackexchange.com/questions/128991/how-to-calculate-the-area-of-a-3d-triangle
surface_area = sum(norm.(eachrow([x0 y0 z0] - [x1 y1 z1]) .× eachrow([x1 y1 z1] - [x2 y2 z2])) / 2)
return Properties(volume, center_of_gravity, inertia ./ volume, surface_area) return Properties(volume, center_of_gravity, inertia ./ volume, surface_area)
end end

View File

@@ -52,7 +52,7 @@ end
models = Dict( models = Dict(
# Inertia math: https://en.wikipedia.org/wiki/List_of_moments_of_inertia#List_of_3D_inertia_tensors # Inertia math: https://en.wikipedia.org/wiki/List_of_moments_of_inertia#List_of_3D_inertia_tensors
# Properties(volume, center_of_gravity, inertia) # Properties(volume, center_of_gravity, inertia, surface_area)
"cube.stl" => Properties(2.0^3, center, I_mat .* 2^2 / 6, 6 * 2^2), # l = 2 "cube.stl" => Properties(2.0^3, center, I_mat .* 2^2 / 6, 6 * 2^2), # l = 2
"sphere.stl" => Properties(4 / 3 * pi, center, I_mat .* 2 / 5, 4π), # r = 1 "sphere.stl" => Properties(4 / 3 * pi, center, I_mat .* 2 / 5, 4π), # r = 1
"2_4_8_cuboid.stl" => "2_4_8_cuboid.stl" =>