Raycasting Evenly in Arbitrary Hemisphere?

Blitz3D Forums/Blitz3D Programming/Raycasting Evenly in Arbitrary Hemisphere?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This may be of some help too:



Finding UNFORM random points on a sphere: (Ie: no pole clustering)
----------------------------------
choose a random angle t and a random number z between -1 and 1, then let r=sqrt(1-z^2), x=r*cos(t), y=r*sin(t).
then (x,y,z) is a random point on the sphere
(of radius 1, centered at the origin)


OR:

To generate a random point on the sphere, it is necessary only to generate two random numbers,
z between -R and R,

phi between 0 and 2 pi, each with a uniform distribution

To find the latitude (theta) of this point, note that z=Rsin(theta), so:

theta=sin-1(z/R)

its longitude is phi.

In rectilinear coordinates:

x=R*cos(theta)*cos(phi)
y=R*cos(theta)*sin(phi)
z=R*sin(theta)=z

Note that in both methods points will appear to be clustered if you attempt to step through it. The lattitude lines become more sparse as the longitude lines become

more dense, so random points will be evenly distributed, but if you plot even lonigtude lines it will look wrong.



if you enclose a sphere in a cylinder (with no top or bottom) then the sphere and the cylinder have the same surface area.

moreover,if you project from the cylinder to the sphere, towards the axis of the cylinder, then this projection preserves area.

so, to choose random points on a sphere, you can just choose random points on a vertical cylinder, then project the points horizontally to the sphere.

The height of the cylinder is the diameter of the sphere.