LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poolable { public Vector3 random(final Vector3 store) { Vector3 result = store; if (result == null) { result = new Vector3(); } final double rand = MathUtils.nextRandomDouble(); result.setX(2 * _extent * getOrigin().getX() * (1 - rand) + getDirection().getX() * _extent * (2 * rand - 1)); result.setY(2 * _extent * getOrigin().getY() * (1 - rand) + getDirection().getY() * _extent * (2 * rand - 1)); result.setZ(2 * _extent * getOrigin().getZ() * (1 - rand) + getDirection().getZ() * _extent * (2 * rand - 1)); return result; } LineSegment3();  LineSegment3(final ReadOnlyLineSegment3 source);  LineSegment3(final ReadOnlyVector3 origin, final ReadOnlyVector3 direction, final double extent);  LineSegment3(final ReadOnlyVector3 start, final ReadOnlyVector3 end); LineSegment3 set(final ReadOnlyLineSegment3 source); @Override double getExtent(); void setExtent(final double extent); Vector3 getPositiveEnd(final Vector3 store); Vector3 getNegativeEnd(final Vector3 store); @Override double distanceSquared(final ReadOnlyVector3 point, final Vector3 store); Vector3 random(final Vector3 store); static boolean isValid(final ReadOnlyLineSegment3 segment); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); @Override LineSegment3 clone(); @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 LineSegment3 fetchTempInstance(); final static void releaseTempInstance(final LineSegment3 segment);  }
@Test public void testRandom() { MathUtils.setRandomSeed(0); final LineSegment3 seg1 = new LineSegment3(); final Vector3 store = seg1.random(null); assertEquals(new Vector3(0.0, 0.0, 0.23096778737665702), store); seg1.random(store); assertEquals(new Vector3(0.0, 0.0, -0.25946358432851413), store); }