sphereCartesian static method
Returns a three-dimensional search space with spherical
geometry.
- The sphere is centred at
centre
.
- The coordinates are specified as:
[x, y, z]
where
Implementation
static SearchSpace sphereCartesian({
num radius = 1.0,
List<num> centre = const <double>[0.0, 0.0, 0, 0],
}) {
// Define intervals.
final x0 = centre[0];
final y0 = centre[1];
final z0 = centre[2];
final x = FixedInterval(
x0 - radius,
x0 + radius,
);
final y = ParametricInterval(
() =>
y0 -
sqrt(
pow(radius, 2) - pow(x.next() - x0, 2),
),
() =>
y0 +
sqrt(
pow(radius, 2) - pow(x.next() - x0, 2),
),
);
final z = ParametricInterval(
() =>
z0 -
sqrt(
pow(radius, 2) - pow(y.next() - y0, 2) - pow(x.next() - x0, 2),
),
() =>
z0 +
sqrt(
pow(radius, 2) - pow(y.next() - y0, 2) - pow(x.next() - x0, 2),
),
);
return SearchSpace.parametric([x, y, z], order: []);
}