I am writing a program to simulate a disintegration of an object into two parts.
I have a vector which represents the direction of motion of the object. This vector has angles $\theta$ and $\phi$ (I am using the physics convention, so inclination $\theta$, azimuth $\phi$.
Now I sample phi and the cosine of theta, cos($\theta_{new}$) and $\phi_{new}$ from some arbitrary distribution (take a uniform one for example).
I want to use these two angles, to initialise the vector of one of the parts after disintegration, the other vector will be rotated by pi (the two parts will fly "back to back").
However, the parts should disintegrate relative to the direction of motion of the object. So I need to add an angle to $\theta_{new}$ so that the vector of the object is the new "z-axis" (phi is not important, I assume azimuthal symmetry around the direction of motion of the object) and the vector of one of the parts makes an cosine of cos($\theta_{new}$) relative to the direction of the object.
My first thought was this:
- From the vector of the object, compute $\theta_{Object}$ and $\phi_{Object}$
- Sample cos($\theta_{new}$) and $\phi_{new}$ according to some arbitrary distribution
- Add $\theta_{Object}$ to $\theta_{new}$ and use this sum to initialise the vector of one of the parts (e.g the vector will be
[sin($\theta_{sum}$)cos($\phi_{sum}$),sin($\theta_{sum}$)sin($\phi_{sum}$),cos($\theta_{sum}$)]
However this didn't work. If I simulate this process for a lot of times, and via the dot product, find cos($\theta_{sum}$) and plot its distribution, it will not be flat (if angles are sampled uniformly)
I thought this had to do with the problem that $\theta_{sum}$ could be larger then $\pi$
My next idea then was this:
If $\theta_{sum} <= \pi$: continue like above
Else: Initialise the vector with $\theta = \pi - \theta_{new} + \theta_{Object}$, then rotate it by 180 degrees by multiplying it with -1.
However, this also doesn't reproduce the right distribution
Not sure however why this doesn't work.
To carry $\hat z=(0,0,1)$ to $\hat v=(\sin\theta\cos\phi,\sin\theta\sin\phi,\cos\theta)$ you need to rotate $\hat z$ first by an angle of $\theta$ around $y$-axis, then by an angle of $\phi$ around $z$-axis. The rotation matrix performing that is thus: $$ R=\pmatrix{\cos\phi &-\sin\phi & 0\\ \sin\phi &\cos\phi & 0\\ 0 & 0 & 1}\cdot \pmatrix{\cos\theta & 0 &\sin\theta\\ 0 & 1 & 0 \\ -\sin\theta & 0 &\cos\theta} =\pmatrix{\cos\theta\cos\phi & -\sin\phi &\sin\theta\cos\phi\\ \cos\theta\sin\phi & \cos\phi &\sin\theta\sin\phi \\ -\sin\theta & 0 &\cos\theta}. $$ Now take your vector $v_{new}$ and apply to it this rotation.