mirror of
https://gitlab.com/MisterBiggs/stl-process.git
synced 2025-08-05 13:01:23 +00:00
added surface area calculation
This commit is contained in:
@@ -3,17 +3,19 @@ module stlProcess
|
||||
using MeshIO
|
||||
using FileIO
|
||||
using Roots
|
||||
using LinearAlgebra
|
||||
|
||||
struct Properties
|
||||
volume::Float64
|
||||
center_of_gravity::Vector{Float64}
|
||||
inertia::Matrix{Float64}
|
||||
surface_area::Float64
|
||||
|
||||
function Properties(volume, center_of_gravity, inertia)
|
||||
function Properties(volume, center_of_gravity, inertia,surface_area)
|
||||
@assert size(center_of_gravity) == (3,)
|
||||
@assert size(inertia) == (3, 3)
|
||||
|
||||
return new(volume, center_of_gravity, inertia)
|
||||
return new(volume, center_of_gravity, inertia, surface_area)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,7 +76,9 @@ 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])
|
||||
|
||||
return Properties(volume, center_of_gravity, inertia ./ volume)
|
||||
surface_area = norm.(eachrow([x0 y0 z0] - [x1 y1 z1]) .× eachrow([x1 y1 z1] - [x2 y2 z2])) / 2 |> sum
|
||||
|
||||
return Properties(volume, center_of_gravity, inertia ./ volume, surface_area)
|
||||
end
|
||||
|
||||
function fast_volume(triangles; scale=1)
|
||||
|
Reference in New Issue
Block a user