diff --git a/ShoulderCase/@Glenoid/measureCenter.m b/ShoulderCase/@Glenoid/measureCenter.m new file mode 100644 index 0000000..af79e5d --- /dev/null +++ b/ShoulderCase/@Glenoid/measureCenter.m @@ -0,0 +1,8 @@ +function measureCenter(obj) + % Glenoid center is the closet point between the mean of the extracted + % surface and all the points of the extracted surface. + meanPoint = mean(obj.surface.points); + surfacePointsToMeanPoint = obj.surface.points - meanPoint; + centerIndex = findShortest3DVector(surfacePointsToMeanPoint); + obj.center = obj.surface.points(centerIndex,:); +end diff --git a/ShoulderCase/findShortest3DVector.m b/ShoulderCase/findShortest3DVector.m new file mode 100644 index 0000000..d2c8227 --- /dev/null +++ b/ShoulderCase/findShortest3DVector.m @@ -0,0 +1,11 @@ +function index = findShortest3DVector(vectors) + dimension = find(size(vectors) == 3); + if (dimension ~= 2) + error('You should provide an Nx3 vector array'); + index = 0; + return + end + type = 2; + norms = vecnorm(vectors,type,dimension); + index = find(norms == min(norms)); +end