cone static method
Implementation
static SearchSpace cone({
num rhoMin = 0,
num rhoMax = 2,
num phiMin = 0,
num phiMax = 2 * pi,
num zMin = 0,
num zMax = 2,
}) {
// Validated input.
final rhoInput = [rhoMin, rhoMax];
rhoMin = rhoInput.min();
rhoMax = rhoInput.max();
final zInput = [zMin, zMax];
zMin = zInput.min();
zMax = zInput.max();
if (rhoMin < 0) {
throw ErrorOf<SearchSpace>(
message: 'Error in function SearchSpace.cone().',
invalidState: 'Negative radius found: rhoMin: $rhoMin',
expectedState: 'A positive value for parameter <rho>.');
}
if (rhoMax < 0) {
throw ErrorOf<SearchSpace>(
message: 'Error in function SearchSpace.cone().',
invalidState: 'Negative radius found: rhoMin: $rhoMin',
expectedState: 'A positive value for parameter <rho>.');
}
// Define intervals.
final z = FixedInterval(
zMin,
zMax,
inverseCdf: InverseCdfs.zCone,
name: 'z',
);
final phi = PeriodicInterval(phiMin, phiMax, name: 'phi');
// /// Radius as a function of the vertical coordinate.
// num rhoParam(num z) {
// return (-z * (rhoMax - rhoMin) + rhoMax * zMax - rhoMin * zMin) /
// (zMax - zMin);
// }
final dz = zMax - zMin;
if (dz == 0) {
throw ErrorOf<SearchSpace>(
message: 'Error in function SearchSpace.cone().',
invalidState: 'Height of cone is: $dz',
expectedState: 'zMax - zMin != 0.');
}
final dzMid = rhoMin / rhoMax * dz;
final zMid = zMin + dzMid;
final rho = ParametricInterval(
() => z.next() < zMid ? rhoMin / dzMid * (zMid - z.next()) : 0.0,
() => rhoMax / dz * (zMax - z.next()),
inverseCdf: InverseCdfs.triangular,
name: 'rho');
return SearchSpace.parametric([rho, phi, z], order: [2, 1, 0]);
}