Re: Random directions
- From: "Jim Hnat" <jhnat@xxxxxxxxx>
- Date: Tue, 1 Aug 2006 18:45:29 -0400
Thanks Roger.
I am trying to solve this problem using unit vectors in 3D space and
I would like a uniform distribution. Essentially, I am trying to
generate synthetic crystal axes in real space.
That worked really well. Thanks alot!!
Roger Stafford wrote:
.
In article <ef3d2f4.-1@xxxxxxxxxxxxxxxxxxxxxxx>, "Jim Hnat"
<jhnat@xxxxxxxxx> wrote:
Dear Matlab users,angle
I am trying to generate randomly oriented vectors, knowing the
between the random vector (RV) and a fixed vector (FV).Essentially
this gives me a cone about the FV.rand()
Because the RV is a fixed angle from the FV, trying to use the
funtion for one of the direction cosines of RV and solving forthe
other two is not possible.-------------------------------------
How might I go about generating these random vectors?
Thanks
-Jim
I have a few questions here. First, are you talking about
three-element
vectors in three-dimensional space? I will assume here that that
is the
case. Second, what sort of random distribution on the cone do you
wish to
have? You probably want a uniform distribution of the angle
transversely
around the cone over a 2*pi span, but what is the distribution to
be along
the length of the cone? It can't be uniform since the length is
infinite. Also it can't be uniform over the surface area of the
cone
since that is infinite too. Perhaps you are only interested in
unit
length vectors? I will temporarily assume you want unit length
random
vectors.
Let 'alpha' be the specified angle between RV and FV. Use
matlab's
'null' function on the column vector FV to obtain two orthonormal
column
vectors which are also orthogonal to FV. Call them p and q.
x = null(FV.'); p = x(:,1); q = x(:,2); % Two orthonormal vectors
beta = 2*pi*rand; % Random transverse angle
RV = FV/norm(FV)*cos(alpha)+(p*sin(beta)+q*cos(beta))*sin(alpha);
If you don't want to be restricted to unit length vectors, then
generate
a random length, 'r', with whatever distribution you desire for the
length
and do:
RV = r*RV;
If you want more than three-element vectors, that is a deeper
problem.
I'll wait to hear from you about that.
Roger Stafford
- References:
- Random directions
- From: Jim Hnat
- Re: Random directions
- From: Roger Stafford
- Random directions
- Prev by Date: Re: BPSK BER simulation
- Next by Date: Skeletonization
- Previous by thread: Re: Random directions
- Next by thread: Voice Recognation
- Index(es):
Relevant Pages
|