geometry - center of mass 3d matlab -
i have sparse 3d volume (cube), @ each x,y location want create sphere radius r, center located @ x,y,z. each sphere want compute center of mass.
my questions:
the points within each sphere not evenly distributed, center of mass not centroid, how compute center of mass ? found many different ways...
i need compute @ each
size(x)*size(y)
times, can quite large, can create 3d sphere this:w = ceil(r)*2+1; [x,y,z] = meshgrid(1:w,1:w,1:w); xc = floor(w./2)+1; yc = floor(w./2)+1; zc = floor(w./2)+1; mask = (x-xc).^2 + (y-yc).^2 + (z-zc).^2 <= r.^2; mask = double(mask);
but make me go loop each point, , time consuming. matlabit
take @ update step of k-means clustering, find center of mass sphere.
to find points should included in sphere calculate , threshold euclidean distance between centroid of sphere , each point. if distance less sphere's radius include it.
do in 3 deep nested loop on set of x,y,z sphere centroids, , you're done.
Comments
Post a Comment