Class TetrahedronSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.shape.TetrahedronSampler
-
- All Implemented Interfaces:
ObjectSampler<double[]>,SharedStateObjectSampler<double[]>,SharedStateSampler<SharedStateObjectSampler<double[]>>
public class TetrahedronSampler extends Object implements SharedStateObjectSampler<double[]>
Generate points uniformly distributed within a tetrahedron.-
Uses the algorithm described in:
Rocchini, C. and Cignoni, P. (2001)
Generating Random Points in a Tetrahedron.
Journal of Graphics Tools 5(4), pp. 9-12.
Sampling uses:
- Since:
- 1.4
- See Also:
- Rocchini, C. & Cignoni, P. (2001) Journal of Graphics Tools 5, pp. 9-12
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TetrahedronSamplerof(UniformRandomProvider rng, double[] a, double[] b, double[] c, double[] d)Create a tetrahedron sampler with verticesa,b,candd.double[]sample()Create an object sample.TetrahedronSamplerwithUniformRandomProvider(UniformRandomProvider rng)Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.sampling.ObjectSampler
samples, samples
-
-
-
-
Method Detail
-
sample
public double[] sample()
Description copied from interface:ObjectSamplerCreate an object sample.- Specified by:
samplein interfaceObjectSampler<double[]>- Returns:
- a random Cartesian point within the tetrahedron.
-
withUniformRandomProvider
public TetrahedronSampler withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateObjectSampler<double[]>>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
of
public static TetrahedronSampler of(UniformRandomProvider rng, double[] a, double[] b, double[] c, double[] d)
Create a tetrahedron sampler with verticesa,b,candd. Sampled points are uniformly distributed within the tetrahedron.No test for a volume is performed. If the vertices are coplanar the sampling distribution is undefined.
- Parameters:
rng- Source of randomness.a- The first vertex.b- The second vertex.c- The third vertex.d- The fourth vertex.- Returns:
- the sampler
- Throws:
IllegalArgumentException- If the vertices do not have length 3; or vertices have non-finite coordinates
-
-