  | | | Random points on a unit sphere without biasing | Random points on a unit sphere without biasing 2005-06-14 - By kim aldis
Back You'd have to be very sure of your random number generator before you could be sure about this visually. Some of the built in or system ones can be pretty awful. I recall doing a visual test under Data General U/X a while back, generating random numbers within an xyz cube and displaying them up on a 3D display as a star field. There was an entire diagonal plane slice that had absolutely nothing in it right through the middle.
You're right about the cube thing, though. Doh. You'd be projecting through more of the cube from the corners so you'd get a greater density. Using a big cube would help, the ratio of the distance to the corner against the distance to the perpendicular plane would be close to 1 and the bias minimised.
> -- --Original Message-- -- > From: owner-xsi@(protected) > [mailto:owner-xsi@(protected)] On Behalf Of Andy Jones > Sent: 14 June 2005 21:20 > To: XSI@(protected) > Subject: Re: Random points on a unit sphere without biasing > > This is interesting. I haven't done the math on quaternions > to see if this should work, but when I run the script, my eye > is telling me there's a slight bias around the X-axis > equator. Of course, I don't think every possible value of a > 2x2 matrix in [-1,1] defines a valid quaternion, so it could > be that the bias is coming from the particular mapping the > quaternion set method is using to go from that matrix space > to the space of valid quaternions. > > -Andy > > Bradley R. Gabe wrote: > > > It's an interesting exercise. I'm not a mathematician by > any stretch, > > but here's a little jscript that'll distribute points in a > unit sphere > > by randomly calculating a quaternion rotation, then transforming 1 > > unit from origin. I use a particle cloud to visualize the point > > distribution. > > > > // SPHERICAL POINT DIST > > var radius = 0.5; > > var pnts = 1000; > > > > // Create New particle Type > > var pTypeColl = CreateParticleType(); > > pType = pTypeColl(0); > > > > // Create Cloud > > var cloud = ActiveSceneRoot.AddParticleCloud(); > > var cloudPrim = cloud.ActivePrimitive; > > cloudPrim.AddParticles(pnts, pType); > > particles = cloudPrim.Particles; > > > > > > // For each particle, set a random distribution > > for(var i=0; i<pnts; i++){ > > > > // Get XSIMath objects for calculating random rot > > var rot = XSIMath.CreateRotation(); > > var q1 = XSIMath.CreateQuaternion(); > > var trans = XSIMath.CreateTransform(); > > var pos = XSIMath.CreateVector3(); > > var radPos = XSIMath.CreateVector3(); > > radPos.Set(radius, 0,0); > > > > // Calculate random quaternions > > var W = Math.random() * 2 - 1; > > var X = Math.random() * 2 - 1; > > var Y = Math.random() * 2 - 1; > > var Z = Math.random() * 2 - 1; > > q1.set(W,X,Y,Z); > > > > // Create a unit transform from quaternion rotation > > rot.SetFromQuaternion(q1); > > trans.SetRotation(rot); > > trans.AddLocalTranslation(radPos); > > trans.GetTranslation(pos); > > > > // Set particle to unit transform; > > particles(i).position = pos; > > > > } > > > > > > > >> Hi All, > >> > >> This is to the maths geniuses in the room. I want to > generate X number > >> of points on a unit sphere, but be sure I won't have any biasing > >> involved. > >> > >> My first thought was just to use a couple of random numbers (let's > >> assume they don't have any bias) and then use those with a > few sin and > >> cos function etc to generate the points. Though I have a > feeling that > >> would give me more points around the poles. > >> > >> Anyone have some good suggestions? > >> > >> Cheers, > >> > >> Alan. > >> > >> --- > >> Unsubscribe? Mail Majordomo@(protected) with the > following text in > >> body: > >> unsubscribe xsi > > > > --- > Unsubscribe? Mail Majordomo@(protected) with the following > text in body: > unsubscribe xsi > >
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|
 |