Skip to content
Advertisement

Sample points from a hyperboloid

A hyperboloid has the formula

-x^2/a^2 – y^2/b^2 + z^2/c^2 = 1.

How can I generate samples from this hyperboloid in Python? (Say, with a=b=c=1.)

I was thinking to pick random x and y in [0,1] and then fill in the z value that would make the formula equal 1. However this would not sample uniformly. Is there a better way?

Advertisement

Answer

This is only a partial answer.

J.F. Williamson, “Random selection of points distributed on curved surfaces”, Physics in Medicine & Biology 32(10), 1987, describes a general method of choosing a uniformly random point on a parametric surface. It is an acceptance/rejection method that accepts or rejects each candidate point depending on its stretch factor (norm-of-gradient). To use this method for a parametric surface, several things have to be known about the surface, namely—

  • x(u, v), y(u, v) and z(u, v), which are functions that generate 3-dimensional coordinates from two dimensional coordinates u and v,

  • The ranges of u and v,

  • g(point), the norm of the gradient (“stretch factor”) at each point on the surface, and

  • gmax, the maximum value of g for the entire surface.

The algorithm is then:

  1. Generate a point on the surface, xyz.
  2. If g(xyz) >= RNDU01()*gmax, where RNDU01() is a uniform random number in [0, 1), accept the point. Otherwise, repeat this process.

In the case of a hyperboloid with parameters a=b=c=1:

  • The gradient is [2*x, -2*y, 2*z].
  • The maximum value of the gradient norm is:2*sqrt(3), if x, y, and z are all in the interval [0, 1].

The only thing left is to turn the implicit formula into a parametric equation that is a function of two-dimensional coordinates u and v. I know this algorithm works for parametric surfaces, but I don’t know if it still works if we “pick random x and y in [0,1] and then fill in the z value that would make the formula equal” in step 1.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement