your elipsoid have width a in x-direction, b in y-direction and c in z-direction.
generate a cube around it (just take 2*max(a,b,c) to get its size, and place it around 0,0,0 as well.. so its "radius" is max(a,b,c) .. i know, terrible explanation:D).
generate a random point in the cube. (hope you get that:D)
do { p = generate_point_in_cube(max(a,b,c)); p_unit_sphere = p; p_unit_sphere.x /= a; p_unit_sphere.y /= b; p_unit_sphere.z /= c;while(p_unit_sphere.squared_length()>1.f);
where the cube func could look like this:
point generate_point_in_cube(half_width) { p = 0; p.x = srand()*half_width; p.y = srand()*half_width; p.z = srand()*half_width; return p;}
where
max(a,b,c) == max(a,max(b,c))
and srand returns a value between -1 and 1
that should work and generate random points uniformly distributed in an elipsoid with the sizes a,b,c..
anyone having any problems with that?
"take a look around" - limp bizkit
www.google.com