<blockquote>
<p>do the velocity coordinates transform the same way as my spatial coordinates?</p>
</blockquote>
<p>Yes!</p>
<blockquote>
<p>Should I just be taking the v_zr, v_xr and v_yr and dot product them with the z-axis: [0,0,1]? Then all we are left with are the v_zr.</p>
</blockquote>
<p>Yes!</p>
<blockquote>
<p>Do I have to take into account rotating frame of reference vs inertial frame or would that be redundant?</p>
</blockquote>
<p>The non rotated frame and the rotated one are both inertial. So, no need to bother with non-inertial reference frames, that's good news, I suppose.</p>
<blockquote>
<p>Feel free to suggest if you have any other alternative definitions of inclination.</p>
</blockquote>
<p>In order to obtain a more general rotation and sample every possible orientation of the galaxy in 3D space (assuming this is what you want to do), you could multiply together three rotation matrices: a rotation about the x-axis, a rotation about the y-axis and a rotation about the z-axis.</p>
<p>You say you feel lost, but instead you seem to know very well what you are doing. Everything you said looks correct, be more confident in yourself!</p>

CC BY-SA 4.0
2021-08-21T07:52:29.880Z
Thanks a lot, Prallax for the confirmation and encouraging words! You sound like a terrific astro buddy :)
Jerome
CC BY-SA 4.0
2021-08-21T10:37:58.337Z
@Jerome You are welcome. Remember to accept the answer if you think it solves your problem. And good luck!
Prallax
CC BY-SA 4.0
2021-08-21T12:43:28.657Z
Thanks @Prallax but I will keep it open in case somebody else has alternative answers :)
Jerome
CC BY-SA 4.0
2021-08-20T12:29:18.060Z
2021-08-20T12:29:18.060Z
Prallax
<p>I am trying to calculate the mean line of sight velocity from a simulation snapshot of a galaxy after the galaxy is inclined by a certain angle, theta. I am coding it in python.
What I have done so far:
I have extracted the [x,y,z] and [v_x,v_y,v_z] coordinates (x,y,z components of velocity coordinates) of the stars in the galaxy. There are many stars so there are many coordinates[[x1,y1,z1]...[xn,yn,zn]] and [[v_x1,v_y1,v_z1]...[v_xn,v_yn,v_zn]] etc. I have rotated the galaxy about the x-axis by an angle theta using the 3D rotation matrix.</p>
<p>This rotates z and y coordinates and not x. When our line of sight is either along z-axis or along y-axis then rotating in this manner along the x-axis will lead to an inclined image of the galaxy. At least this is how I am defining inclination. Feel free to suggest if you have any other alternative definitions of inclination.</p>
<p>Now, I can calculate my rotated x,y,z coordinates and they give different shapes of my galaxy, depending on my line of sight. eg. if my line of sight is z-axis, the galaxy is face-on when theta=0 and elliptical if I take theta=45 degrees.
My questions are:</p>
<ol>
<li>do the velocity coordinates transform the same way as my spatial coordinates? That is, after rotation will my v_x, v_y and v_z  be transformed using the 3D rotation matrix I mentioned before?</li>
<li>After rotation, if my line of sight is the z-axis, then how should I calculate the projection of the velocities along the z-axis? (Let's call the velocity coordinates after rotation v_xr, v_yr, v_zr to avoid any confusion. So, we will be getting rotated velocity coordinates as [[v_xr1,v_yr1,v_zr1],....[v_xrn,v_yrn,v_zrn]]) Should I just be taking the v_zr, v_xr and v_yr and dot product them with the z-axis: [0,0,1]? Then all we are left with are the v_zr. To get the mean I just take average of all v_zr.</li>
</ol>
<p>I feel like this is not all there is to it and I might be missing something or is this the final answer?...is there a different way to calculate the projection of the velocities along the line of sight? Do I have to take into account rotating frame of reference vs inertial frame or would that be redundant? If you also have any literature relevant to this that you think I might find useful please do share.</p>
<p>Thanks so much in advance.</p>

<galaxy><velocity><n-body-simulations>
How to calculate mean line of sight velocity of stars after rotation of galaxy?
Jerome
# How to calculate mean line of sight velocity of stars after rotation of galaxy?

(Asked by: username_0 on 2021-08-20)

I am trying to calculate the mean line of sight velocity from a simulation snapshot of a galaxy after the galaxy is inclined by a certain angle, theta. I am coding it in python.
What I have done so far:
I have extracted the [x,y,z] and [v\_x,v\_y,v\_z] coordinates (x,y,z components of velocity coordinates) of the stars in the galaxy. There are many stars so there are many coordinates[[x1,y1,z1]...[xn,yn,zn]] and [[v\_x1,v\_y1,v\_z1]...[v\_xn,v\_yn,v\_zn]] etc. I have rotated the galaxy about the x-axis by an angle theta using the 3D rotation matrix.

This rotates z and y coordinates and not x. When our line of sight is either along z-axis or along y-axis then rotating in this manner along the x-axis will lead to an inclined image of the galaxy. At least this is how I am defining inclination. Feel free to suggest if you have any other alternative definitions of inclination.

Now, I can calculate my rotated x,y,z coordinates and they give different shapes of my galaxy, depending on my line of sight. eg. if my line of sight is z-axis, the galaxy is face-on when theta=0 and elliptical if I take theta=45 degrees.
My questions are:

1. do the velocity coordinates transform the same way as my spatial coordinates? That is, after rotation will my v\_x, v\_y and v\_z be transformed using the 3D rotation matrix I mentioned before?
2. After rotation, if my line of sight is the z-axis, then how should I calculate the projection of the velocities along the z-axis? (Let's call the velocity coordinates after rotation v\_xr, v\_yr, v\_zr to avoid any confusion. So, we will be getting rotated velocity coordinates as [[v\_xr1,v\_yr1,v\_zr1],....[v\_xrn,v\_yrn,v\_zrn]]) Should I just be taking the v\_zr, v\_xr and v\_yr and dot product them with the z-axis: [0,0,1]? Then all we are left with are the v\_zr. To get the mean I just take average of all v\_zr.

I feel like this is not all there is to it and I might be missing something or is this the final answer?...is there a different way to calculate the projection of the velocities along the line of sight? Do I have to take into account rotating frame of reference vs inertial frame or would that be redundant? If you also have any literature relevant to this that you think I might find useful please do share.

Thanks so much in advance.

**Tags:** galaxy, velocity, n-body-simulations


---

## 1 answers

### Answer by username_1 on 2021-08-20. Score: 3 | Accepted answer

> do the velocity coordinates transform the same way as my spatial coordinates?

Yes!

> Should I just be taking the v\_zr, v\_xr and v\_yr and dot product them with the z-axis: [0,0,1]? Then all we are left with are the v\_zr.

Yes!

> Do I have to take into account rotating frame of reference vs inertial frame or would that be redundant?

The non rotated frame and the rotated one are both inertial. So, no need to bother with non-inertial reference frames, that's good news, I suppose.

> Feel free to suggest if you have any other alternative definitions of inclination.

In order to obtain a more general rotation and sample every possible orientation of the galaxy in 3D space (assuming this is what you want to do), you could multiply together three rotation matrices: a rotation about the x-axis, a rotation about the y-axis and a rotation about the z-axis.

You say you feel lost, but instead you seem to know very well what you are doing. Everything you said looks correct, be more confident in yourself!

> **Comments:**
> **username_0**: Thanks a lot, username_1 for the confirmation and encouraging words! You sound like a terrific astro buddy :)  
> **username_1**: @username_0 You are welcome. Remember to accept the answer if you think it solves your problem. And good luck!  
> **username_0**: Thanks @username_1 but I will keep it open in case somebody else has alternative answers :)  

---

