code:
def get_random_unit_vector():
t = np.random.uniform(0.0, 2 * np.pi)
sin_t, cos_t = np.sin(t), np.cos(t)
z = np.random.uniform(-1.0, 1.0)
z_height = np.sqrt(1.0 - z*z)
return np.array([cos_t * z_height, sin_t * z_height, z])
random_vectors = [get_random_unit_vector() for _ in range(500)]
fig = plt.figure()
ax = plt.figure().add_subplot(projection='3d')
for v in random_vectors:
ax.quiver(0, 0, 0, v[0], v[1], v[2])
# Set axis limits
ax.set_xlim([-1.5, 1.5])
ax.set_ylim([-1.5, 1.5])
ax.set_zlim([-1.5, 1.5])
plt.show()
why is one axis of the plot shorter than the other two?
