Coordinate transformations methods¶
- class pNbody._coordinate_transformations_mixin._NbodyCoordinateTransformationsMixin¶
Bases:
object- sphericalvel2pos()¶
Replace Cartesian positions with spherical velocity components.
This method performs an in-place update of the pos attribute, mapping the calculated spherical velocity components ($v_r, v_{ heta}, v_{phi}$) directly to the Cartesian axes ($x, y, z$).
The mapping is assigned as follows: *
pos[:, 0](x-axis) $leftarrow$ $v_r$ (Radial velocity) *pos[:, 1](y-axis) $leftarrow$ $v_{ heta}$ (Polar/Theta velocity) *pos[:, 2](z-axis) $leftarrow$ $v_{phi}$ (Azimuthal/Phi velocity)Notes
This operation is destructive to the original spatial position data. It is typically used to analyze the velocity-space structure in spherical coordinates.
- vel2pos()¶
Replace particle positions with their current velocity vectors.
This method performs an in-place update of the pos attribute, mapping the Cartesian velocity components ($v_x, v_y, v_z$) directly to the Cartesian position coordinates ($x, y, z$).
This is commonly used in phase-space analysis or when visualizing velocity-space distributions.
Notes
This operation is destructive to the original position data unless it has been backed up elsewhere.
- vel_cart2cyl(pos=None, vel=None)¶
Transform velocities from Cartesian to cylindrical coordinates.
Convert velocity components ($v_x, v_y, v_z$) into ($v_R, v_T, v_z$). The resulting $v_R$ represents radial motion in the xy-plane, and $v_T$ represents tangential (azimuthal) motion.
- Parameters
pos (ndarray, optional) – A (N, 3) array of Cartesian positions [x, y, z]. If None, uses self.pos. Default is None.
vel (ndarray, optional) – A (N, 3) array of Cartesian velocities [vx, vy, vz]. If None, uses self.vel. Default is None.
- Returns
A (N, 3) float32 array of cylindrical velocities [vR, vT, vz].
- Return type
ndarray
- vel_cyl2cart(pos=None, vel=None)¶
Transform velocities from cylindrical to Cartesian coordinates.
Convert velocity components ($v_R, v_T, v_z$) into ($v_x, v_y, v_z$). The transformation is position-dependent, as it relies on the local azimuthal orientation of each particle.
- Parameters
pos (ndarray, optional) – A (N, 3) array of Cartesian positions [x, y, z]. If None, uses self.pos. Default is None.
vel (ndarray, optional) – A (N, 3) array of cylindrical velocities [vR, vT, vz]. If None, uses self.vel. Default is None.
- Returns
A (N, 3) float32 array of Cartesian velocities [vx, vy, vz].
- Return type
ndarray