You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2021/04/26 11:48:00 UTC
[jira] [Commented] (RNG-131) TriangleSampler: Sample uniformly
within a triangle
[ https://issues.apache.org/jira/browse/RNG-131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17332054#comment-17332054 ]
Gilles Sadowski commented on RNG-131:
-------------------------------------
Regarding the introduction of the {{Coordinates}} class: Is it safe enough to {{requireFinite}} (there are subtractions, linear combinations)?
> 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
> Time Spent: 40m
> 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)