BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Even rand distribution on part of a sphere surface...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Paul Nicholls
Guest





PostPosted: Fri Sep 10, 2004 3:19 am    Post subject: Even rand distribution on part of a sphere surface... Reply with quote



Hi all,
if I have a normal vector, N, on the surface of a sphere, is there an
easy way of generating random points around the vector within an angle
constraint, A, from the vector? Each point needs to be on the surface of
the sphere...

This means each random point needs to be clustered within the 'cone' formed
around the vector by the angle, but on the sphere surface only...

Thanks in advance,
Paul Nicholls (Delphi 5/6 Professional)
"The plastic veneer of civilization is easily melted in the heat of the
moment" - Paul Nicholls
[email]paul-nicholls (AT) hotmail (DOT) com[/email]

Replace '-' with '_' to reply


Back to top
Marcus F.
Guest





PostPosted: Fri Sep 10, 2004 3:51 am    Post subject: Re: Even rand distribution on part of a sphere surface... Reply with quote



"Paul Nicholls" <.> wrote


Quote:
Hi all,
if I have a normal vector, N, on the surface of a sphere, is there an
easy way of generating random points around the vector within an angle
constraint, A, from the vector? Each point needs to be on the surface of
the sphere...

This means each random point needs to be clustered within the 'cone'
formed
around the vector by the angle, but on the sphere surface only...

Without lack of generality, assume the vector N=[0,0,1]. Generate two
uniformly distributed random numbers, "z" between cos(A) and 1, "phi"
between 0 and 2*Pi. Then your random points are at [ (1-z^2)*cos(Phi),
(1-z^2)*sin(Phi), z].



Back to top
Paul Nicholls
Guest





PostPosted: Fri Sep 10, 2004 4:07 am    Post subject: Re: Even rand distribution on part of a sphere surface... Reply with quote



"Marcus F." <a@b.com> wrote

Quote:
"Paul Nicholls" <.> wrote


Hi all,
if I have a normal vector, N, on the surface of a sphere, is there
an
easy way of generating random points around the vector within an angle
constraint, A, from the vector? Each point needs to be on the surface
of
the sphere...

This means each random point needs to be clustered within the 'cone'
formed
around the vector by the angle, but on the sphere surface only...

Without lack of generality, assume the vector N=[0,0,1]. Generate two
uniformly distributed random numbers, "z" between cos(A) and 1, "phi"
between 0 and 2*Pi. Then your random points are at [ (1-z^2)*cos(Phi),
(1-z^2)*sin(Phi), z].


I'm not sure what you meant about "Without lack of generality", and how does
the resulting point change if the vector N is <> [0,0,1]?

Cheers,
Paul.



Back to top
Nils Haeck
Guest





PostPosted: Fri Sep 10, 2004 5:17 am    Post subject: Re: Even rand distribution on part of a sphere surface... Reply with quote

Quote:
I'm not sure what you meant about "Without lack of generality", and how
does
the resulting point change if the vector N is <> [0,0,1]?

Just multiply the random vector with a matrix (3x3) which has the 3rd column
the vector N (scaled to unity), the second column a vector Q that is
perpendicular to N (also unity length), and the 1st column a vector P is the
crossproduct of both. This is a orthonormal transformation.

Something like:

[Px Qx Nx]
M = [Py Qy Ny]
[Pz Qz Nz]

So with

Q dot N = 0 (just choose any Q that works)
Q cross N = P

Make sure that |Q| = 1 and |N| = 1, then |P| = 1 automatically

You can verify that:
[0] [Nx]
M * [0] = [Ny]
[1] [Nz]

Just like that you multiply each Ri with M

Ri-newframe = M * Ri-oldframe

where Ri-oldframe is the random vector created with Marcus' method, and
Ri-newframe is the one in the frame you want relative to [Nx, Ny, Nz]

Hope that helps,

Nils
www.simdesign.nl



Back to top
Paul Nicholls
Guest





PostPosted: Fri Sep 10, 2004 5:33 am    Post subject: Re: Even rand distribution on part of a sphere surface... Reply with quote

"Nils Haeck" <n.haeckno (AT) spamchello (DOT) nl> wrote

Quote:
I'm not sure what you meant about "Without lack of generality", and how
does
the resulting point change if the vector N is <> [0,0,1]?

Just multiply the random vector with a matrix (3x3) which has the 3rd
column
the vector N (scaled to unity), the second column a vector Q that is
perpendicular to N (also unity length), and the 1st column a vector P is
the
crossproduct of both. This is a orthonormal transformation.
SNIP


Thanks Nils, this makes sense :-)

Cheers,
Paul.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.