// Create two rings lying in xy-plane.
final UnitSphereRandomVectorGenerator unit
= new UnitSphereRandomVectorGenerator(2);
final RealDistribution radius1
= new UniformRealDistribution(radiusRing1 - halfWidthRing1,
radiusRing1 + halfWidthRing1);
final RealDistribution widthRing1
= new UniformRealDistribution(-halfWidthRing1, halfWidthRing1);
for (int i = 0; i < numPointsRing1; i++) {
final double[] v = unit.nextVector();
final double r = radius1.sample();
// First ring is in the xy-plane, centered at (0, 0, 0).
firstRing[i] = new Vector3D(v[0] * r,
v[1] * r,
widthRing1.sample());
}
final RealDistribution radius2
= new UniformRealDistribution(radiusRing2 - halfWidthRing2,
radiusRing2 + halfWidthRing2);
final RealDistribution widthRing2
= new UniformRealDistribution(-halfWidthRing2, halfWidthRing2);
for (int i = 0; i < numPointsRing2; i++) {
final double[] v = unit.nextVector();
final double r = radius2.sample();
// Second ring is in the xz-plane, centered at (radiusRing1, 0, 0).
secondRing[i] = new Vector3D(radiusRing1 + v[0] * r,
widthRing2.sample(),
v[1] * r);
}
// Move first and second rings into position.
final Rotation rot = new Rotation(Vector3D.PLUS_K,