mirror of
https://gitlab.com/MisterBiggs/stl-process.git
synced 2025-08-03 12:01:33 +00:00
add comments
This commit is contained in:
@@ -11,7 +11,7 @@ struct Properties
|
||||
inertia::Matrix{Float64}
|
||||
surface_area::Float64
|
||||
|
||||
function Properties(volume, center_of_gravity, inertia,surface_area)
|
||||
function Properties(volume, center_of_gravity, inertia, surface_area)
|
||||
@assert size(center_of_gravity) == (3,)
|
||||
@assert size(inertia) == (3, 3)
|
||||
|
||||
@@ -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[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)
|
||||
end
|
||||
|
@@ -52,7 +52,7 @@ end
|
||||
|
||||
models = Dict(
|
||||
# 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
|
||||
"sphere.stl" => Properties(4 / 3 * pi, center, I_mat .* 2 / 5, 4π), # r = 1
|
||||
"2_4_8_cuboid.stl" =>
|
||||
|
Reference in New Issue
Block a user