sphere static method

SearchSpace sphere({
  1. num rMin = 0,
  2. num rMax = 1,
  3. num thetaMin = 0,
  4. num thetaMax = pi,
  5. num phiMin = 0,
  6. num phiMax = 2 * pi,
})

Returns a three-dimensional search space with spherical geometry.

  • The sphere is centred at the origin.
  • The coordinates are specified as: [r, theta, phi] where r is the radius, theta is polar angle , and phi is angle formed by the x-axis and the projection of the point [r, theta, phi] onto the x-y plane.

Usage:

// Creates a search space consisting of all points on the
// surface of a sphere with unity radius.
final space = SearchSpace.sphere(rMin = 1.0, rMax = 1.0);

// Creates a list with 1000 points sampled from `space`.
final sample = space.sample(size: 1000);

Implementation

static SearchSpace sphere({
  num rMin = 0,
  num rMax = 1,
  num thetaMin = 0,
  num thetaMax = pi,
  num phiMin = 0,
  num phiMax = 2 * pi,
}) {
  // Define intervals.
  final r = FixedInterval(
    rMin,
    rMax,
    name: 'r',
    inverseCdf: InverseCdfs.r,
  );
  final theta = FixedInterval(
    thetaMin,
    thetaMax,
    inverseCdf: InverseCdfs.polarAngle,
    name: 'theta',
  );
  final phi = (phiMin == phiMax)
      ? SingularInterval(phiMin, name: 'phi')
      : PeriodicInterval(phiMin, phiMax, name: 'phi');

  // Defining a spherical search space.
  return SearchSpace.fixed([r, theta, phi], name: 'sphere');
}