Open dwoll opened 1 year ago
Computing the centroid is trivial:
colMeans(Morpho::vert2points(mesh))
The centroid size can be computed byMorpho::cSize(mesh)
Thanks for looking into this! I'm sorry I wasn't precise. I meant the center of mass. For meshes with varying vertex density, the centroid will be drawn to regions with higher density. I've encountered meshes with higher vertex density in high-curvature regions. It would be nice to get the center of mass - CGAL is weighting the individual contributions by triangle size, the reference given by libigl is "Calculating the volume and centroid of a polyhedron in 3d" [Nuernberg 2013]". Many thanks in advance!
Rvcg is an interface to vcglib. I am not sure if this is included.
Center of mass calculation is very similar to volume calculation. Again, my C++ is weak, but I think VCG is doing the weighting in this function (note that function Mass()
as used by Rvcg
in Rmeshvol
is defined right above:
Thanks in advance!
First of all, many thanks for developing Rvcg! It proves extremely useful in radiation oncology where comparison of target structures as contoured by AI vs. experts is currently an important issue. Would it be possible to add a function to obtain the centroid of a mesh, similar to the
vcgVolume()
function? Example calculations based on other libraries are here:https://github.com/CGAL/cgal/blob/40fdc6c6bc48eec140353fca3e930f578745f18b/Principal_component_analysis_LGPL/include/CGAL/centroid.h#L516
https://github.com/libigl/libigl/blob/574ab1a3a819b3798cf452fa44bcb47704a529c6/include/igl/centroid.cpp#L11
Thanks in advance for considering!