Triangle (30k points):
contour: c(x) = 1-x
density: d(x) = a*int(c(x), c) = a*(x-x^2/2)
solve a for d(1) = 1: a = 2
solve y = d(x) for x (one of the solutions): x = 1-sqrt(1-y)
y := frand()
float x = 1-sqrt(1-frand());
vec3 result = vec3(x, (1-x)*frand(), 0);
--------------------------------
Tetrahedron (40k points):
1. make random point in unit cube
2. map the six tetrahedrons that the cube consists of to only one of those tetrahedrons
--------------------------------
Disc (5k points):
float a = 2*constPi()*frand();
vec3 result = vec3(cos(a), 0, sin(a))*acos(cos(constPi()/2*innerRadius)*frand())/(constPi()/2);
--------------------------------
Cylinder (7k points):
= disc with frand() for y
--------------------------------
Sphere (20k points):
float a = 2*constPi()*frand();
float p = constPi()/2-acos(2*frand()-1);
vec3 result = vec3(cos(p)*cos(a), sin(p), cos(p)*sin(a))*root((1-innerRadius**3)*frand()+innerRadius**3, 3.f);
--------------------------------
Programming done in BTPL, display in the Iteration 10 OpenGL graphics engine
http://shrinker.beyond-veils.de/projects/IterationX/
http://shrinker.scottbaker.eu/projects/IterationX/ (mirror)
Link to this comment:
All Comments (0)