You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2021/04/29 12:32:00 UTC
[jira] [Resolved] (RNG-131) TriangleSampler: Sample uniformly
within a triangle
[ https://issues.apache.org/jira/browse/RNG-131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alex Herbert resolved RNG-131.
------------------------------
Fix Version/s: 1.4
Resolution: Implemented
Added to master in commit 6e346fefff881e9fcc0509a5a0af93283089c53a
> TriangleSampler: Sample uniformly within a triangle
> ---------------------------------------------------
>
> Key: RNG-131
> URL: https://issues.apache.org/jira/browse/RNG-131
> Project: Commons RNG
> Issue Type: New Feature
> Components: sampling
> Affects Versions: 1.4
> Reporter: Alex Herbert
> Priority: Minor
> Fix For: 1.4
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> Create a sampler to sample uniformly within a triangle:
> {code:java}
> public abstract class TriangleSampler implements
> SharedStateSampler<TriangleSampler> {
> public static TriangleSampler of(double[] a,
> double[] b,
> double[] c,
> UniformRandomProvider rng);
> }
> {code}
> Sampling of a point p can be performed within a triangle with vertices a, b, c using:
> {noformat}
> v = b - a
> w = c - a
> p = a + s * v + t * w
> with s and t uniform deviates in [0, 1] and s + t <= 1
> Note: When s + t > 1 then transform s = 1 - s and t = 1 - t.{noformat}
> This algorithm is described in:
> Turk, G. Generating random points in triangles. Glassner, A. S. (ed) (1990).
> Graphic Gems, Academic Press, pp. 24-28.
> The method is applicable to any number of dimensions for the vertices. The triangle defines the 2D Euclidean space (plane) for sampling.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)