[V0019] [BTPL] Uniform distributions without sampling

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
62 views
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 2, 2011

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)

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (0)

Sign In or Sign Up now to post a comment!
Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more