runif_in_polygon  R Documentation 
Uniform sampling in a polygon (dimension 2).
runif_in_polygon(n, vertices, center = "centroid")
n 
number of simulations 
vertices 
twocolumns matrix giving the vertices (rows); the vertices must be ordered (clockwise or counterclockwise) 
center 
a point with respect to which the polygon is starshaped, or

This function works for a starshaped polygon, that is, a polygon
that contains a point from which the entire polygon boundary is visible.
This point must be given in the center
argument. If the polygon is
convex, any point inside the polygon is suitable (thus the default option
of the center
argument is appropriate in this case).
The simulations in a n
times 2
matrix.
vs < matrix(c(0.951056516295154, 0.309016994374947,
0.224513988289793, 0.309016994374947,
0.951056516295154, 0.309016994374948,
0.363271264002681, 0.118033988749895,
0.587785252292473, 0.809016994374948,
0.36327126400268, 0.118033988749895,
0, 1,
0.224513988289793, 0.309016994374947,
0.587785252292473, 0.809016994374947,
0, 0.381966011250105),
ncol=2, byrow=TRUE)
sims < runif_in_polygon(500, vs)
plot(sims, xlim = c(1, 1), ylim = c(1, 1), pch = 19, asp = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.