I have a set of particles in a gravitationally bound system. The shape of the particles change with time, I have used a convex hull algorithm to "enclose" the particles of the cloud. I want to find the major and the minor axes of the cloud.
hulls = [hull1, hull2, hull3, hull4, hull5]
for hull in hulls:
for simplex in hull.simplices:
plt.plot(hull.points[simplex, 0], hull.points[simplex, 1], '-', color='black')
points = hull.points[hull.vertices] # shape: (#vertices, #coordinates)
max_distance = 0
major_axis = None
for i in range(len(points)):
for j in range(i + 1, len(points)):
distance = np.linalg.norm(points[i] - points[j])
if distance > max_distance:
max_distance = distance
major_axis = (points[i], points[j])
plt.plot([major_axis[0][0], major_axis[1][0]], [major_axis[0][1], major_axis[1][1]], color='black')
The plot shows the cloud changing with time. Each cloud is for a different time.
I have been able to get the major axes from this. But not the minor axes. How can I do it? Basically just need the distance of the perpendicular through the middle of the major axis. This is a aspect ratio problem. I need the length and width of the cloud. If there is a better way to do this, please let me know.