Re: Random directions



In article <ef3d2f4.-1@xxxxxxxxxxxxxxxxxxxxxxx>, "Jim Hnat"
<jhnat@xxxxxxxxx> wrote:

Dear Matlab users,
I am trying to generate randomly oriented vectors, knowing the angle
between the random vector (RV) and a fixed vector (FV). Essentially
this gives me a cone about the FV.
Because the RV is a fixed angle from the FV, trying to use the rand()
funtion for one of the direction cosines of RV and solving for the
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
.



Relevant Pages

  • Re: OT raibow
    ... Looking at the picture of ray ... and a0 the angle at the vertex of the cone. ... conjecture corresponds to distribution with density concentrated at ...
    (comp.lang.perl.misc)
  • Re: Random directions
    ... I would like a uniform distribution. ... Because the RV is a fixed angle from the FV, ... what sort of random distribution on the cone do you ...
    (comp.soft-sys.matlab)
  • Random directions
    ... between the random vector and a fixed vector. ... this gives me a cone about the FV. ... Because the RV is a fixed angle from the FV, ...
    (comp.soft-sys.matlab)
  • Re: Angles between vectors
    ... The 'Mahalonobis angle' metric will result if you transform ... If we have 5 books by ... that we have a such as the normal distribution defined by two ... I can define my distribution with a single number x. ...
    (sci.stat.math)
  • Re: Cone in a groove
    ... >> Imagine a horizontal symmetrical V-shaped groove with an included angle ... and right circular cone with an included angle of C lying in it. ... What is the angle between the axis ...
    (sci.math)