Connect points in $\mathbb{R}^3$ to form a crystal

43 Views Asked by At

This question is probably more programming oriented, but is theoretically a mathematical problem: I consider $N$ points in space that describe the corners of a crystal. Since a plot of the points does not really help to capture the crystal, I want to connect the points. At first I thought about simply using the average distance between the points. Whenever the distance between two points is smaller than this average distance, a line should be drawn. As simple as that. Unfortunately, the crystal can also look a bit misshapen, see picture. Do you have a good principle in mind for me on how to connect these points? enter image description here

1

There are 1 best solutions below

0
On

Not sure I completely understand the question, but I think what you're looking for is a Convex Hull

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial import ConvexHull


# random points
np.random.seed(1)
points = np.random.uniform(size=(20, 3))

# convex hull
hull = ConvexHull(points)

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

# points
ax.plot(points.T[0], points.T[1], points.T[2], "bo")

# edges
for s in hull.simplices:
    s = np.append(s, s[0])
    ax.plot(points[s, 0], points[s, 1], points[s, 2], "r-")

enter image description here