How to convert an angle vector to Euclidean coordinates given a fixed amplitude, in n dimension
<p>so to convert a polar coordinate (amplitude, angle) to euclidean coordinates in 2D is straight forward. </p>

<p>But in n (say n = 5) dimension, I have a fixed amplitude, and a randomised angle vector. How can I convert it into an euclidean vector of the coordinates?</p>

<pre><code>amp = 0.5
n = 5
ang = np.random.rand(n) * 2* pi
</code></pre>

<p>Many thanks</p>

<p>In 2D, the conversion is:</p>

<pre><code>x = amp * cos(angle)
y = amp * sin(angle)
</code></pre>

<p>In 3D, one option is:</p>

<pre><code>x = amp * cos(angle1) * cos(angle2)
y = amp * sin(angle1) * cos(angle2)
z = amp *               sin(angle2)
</code></pre>

<p>You should see a pattern. The dimensions that already exist get a factor of <code>cos(newAngle)</code>. The new dimension gets <code>sin(newAngle)</code>. So, in 4D, this would be:</p>

<pre><code>x = amp * cos(angle1) * cos(angle2) * cos(angle3)
y = amp * sin(angle1) * cos(angle2) * cos(angle3)
z = amp *               sin(angle2) * cos(angle3)
w = amp *                             sin(angle3)
</code></pre>

<p>In general, the <code>i</code>-th dimension is (1-based):</p>

<pre><code>dim_i = sin(angle_(i-1)) * Product {j from i to n} cos(angle_j)
</code></pre>

<p>(Only if <code>angle_(i-1)</code> exists, otherwise set the term to <code>1</code>).</p>

python math wolfram-mathematica