Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, Poolable { @Override public Vector3 random(final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } final Vector3 b1 = Vector3.fetchTempInstance(); final Vector3 b2 = Vector3.fetchTempInstance(); final double inner2 = _innerRadius * _innerRadius; final double outer2 = _outerRadius * _outerRadius; final double r = Math.sqrt(inner2 + MathUtils.nextRandomFloat() * (outer2 - inner2)); final double theta = MathUtils.nextRandomFloat() * MathUtils.TWO_PI; _up.cross(Vector3.UNIT_X, b1); if (b1.lengthSquared() < MathUtils.EPSILON) { _up.cross(Vector3.UNIT_Y, b1); } b1.normalizeLocal(); _up.cross(b1, b2); result.set(b1).multiplyLocal(r * MathUtils.cos(theta)).addLocal(_center); b2.scaleAdd(r * MathUtils.sin(theta), result, result); Vector3.releaseTempInstance(b1); Vector3.releaseTempInstance(b2); return result; } Ring();  Ring(final ReadOnlyRing source);  Ring(final ReadOnlyVector3 center, final ReadOnlyVector3 up, final double innerRadius,
    final double outerRadius); Ring set(final ReadOnlyRing source); @Override ReadOnlyVector3 getCenter(); void setCenter(final ReadOnlyVector3 center); @Override ReadOnlyVector3 getUp(); void setUp(final ReadOnlyVector3 up); @Override double getInnerRadius(); void setInnerRadius(final double innerRadius); @Override double getOuterRadius(); void setOuterRadius(final double outerRadius); @Override Vector3 random(final Vector3 store); static boolean isValid(final ReadOnlyRing ring); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object o); @Override Ring clone(); @Override Class<? extends Ring> getClassTag(); @Override void write(final OutputCapsule capsule); @Override void read(final InputCapsule capsule); @Override void readExternal(final ObjectInput in); @Override void writeExternal(final ObjectOutput out); final static Ring fetchTempInstance(); final static void releaseTempInstance(final Ring ring);  }
@Test public void testRandom() { MathUtils.setRandomSeed(0); final Ring ring1 = new Ring(); final Vector3 store = ring1.random(null); assertEquals(new Vector3(0.7454530390475868, 0.0, -0.4186496466746111), store); ring1.setUp(Vector3.UNIT_X); ring1.random(store); assertEquals(new Vector3(0.0, 0.30386186434027496, -0.3849731927481824), store); }