This function generates uniform and stratified samples from configurations of planar triangles in 2-dimensional space, optionally with noise.

sample_triangle_planar(n, triangle, bins = 1, sd = 0)

n | Number of observations. |
---|---|

triangle | The (x,y) coordinates of the vertices of a triangle, formatted in a 2x3 matrix |

bins | Number of intervals per dimension to stratify by. Default set to 1, which generates a uniform sample. |

sd | Standard deviation of (independent multivariate) Gaussian noise. |

The sample is generated by an area-preserving parameterization of the planar triangle. This parametrization was derived through the method for sampling 2-manifolds as described by Arvo (2001).

J Arvo (2001) Stratified Sampling of 2-Manifolds. *SIGRAPH 2001 (State of the
Art in Monte Carlo Ray Tracing for Realistic Image Synthesis)*, Course Notes,
Vol. 29. https://www.cs.princeton.edu/courses/archive/fall04/cos526/papers/course29sig01.pdf

set.seed(23004L) #Uniformly sampled equilateral planar triangle in 2-space equilateral_triangle <- cbind(c(0,0), c(0.5,sqrt(3)/2), c(1,0)) x <- sample_triangle_planar(10000, equilateral_triangle) plot(x, asp = 1, pch = 19, cex = .25)