Creating random triangles with points on the radius of a sphere and passing through center

252 Views Asked by At

I'm trying to create a pointy "ball" in 3d space using triangles. I want each triangle to pass through a sphere's center, with each point lying on the surface.

I can easily make points on the surface. Currently I'm doing this by creating a direction vector with random values between -1 and 1. Then I normalize the vector and multiply by the radius to get the final point.

My question is, given two of these points, how can I create a third that is (a) at least semi-random, and (b) ensure it creates a triangle coplanar with the sphere's center.

Update: Forgot to mention, the center of the sphere is always located at (0,0,0)

1

There are 1 best solutions below

1
On BEST ANSWER

Call your two points $P_1$ and $P_2$, and the centre of the sphere $O$. Three points define a plane. Unless $P_1 - O - P_2$ is a line (in which case you can pick any other point on the surface), they define a plane in which the third point $P_3$ must lie.

The intersection of a plane through a sphere's centre with the sphere is a great circle of the sphere. If you cast a line from $P_1$ through $O$ and another from $P_2$ through $O$ you'll delimit the section of the great circle in which $P_3$ must lie to include $O$ in the triangle. You can then parameterise it uniformly by angle: slerp between $-P_1$ and $-P_2$.