This HTML automatically generated with rman for NEMO
Table of Contents


snaprotate - rotate N-body snapshot file about principle axes.


snaprotate in=snap-file out=snap-file [parameter=value] ...


snaprotate rotates the positions and velocities of an N-body snapshot file. A maximum of 3 rotations around either the x, y or z axes can be applied in any order. An Eulerian rotation is a rotation around the z, y and z axes respectively. Some common examples for projections of barred and unbarred galaxies are given in the examples below.

The rotation is counter clock-wise (i.e., mathematically positive, unless invert=f is used) as seen from the right-handed xyz-axes: a z rotation will rotate the x axis towards the y axis, a y rotation will rotate the z axis towards the x axis, and an x rotation will rotate the y axis towards the z axis.

As an example, for a disk in the X-Y plane, a positive Y rotation causes the -X axis to move upwards, towards the observer, i.e. becoming the near side.

An alternate way to specify rotations is using the spinvector= keyword, where all points are rotated around this vector.

Although by default all vectors are rotated by the same matrix, the keyword select= can be used to select any set of Position, Velocity or Acceleration.


The following parameters are recognized; they may be given in any order.
Input data is read from snap-file, which must be in snapshot format.
Output data is written to snap-file.
Angles (in degrees) to rotate particles about the specified axes in the order= keyword. Up to 3 rotations can be applied. Default: none.
Order to apply the rotations about the three coordinate axes. An Eulerian rotation would be order=zyz. Default is none. See also the spinvector keyword below for an alternate way to specify rotations.
If true, invert specified transformation. Useful for rotating something back to original coordinate system. Default is false.
If used, this is the degrees per time-unit that the theta angles are multiplied with in order to calculate the actual rotation angle. This can give interesting effects if used for simulations. Default not used.
Use this vector if you know the vector to rotate around instead of a set of euler angles. Only one angle theta= is needed. Positive rotation is a counterclockwise rotation as seen down the spin vector towards the origin. The vector does not need to be normalized. **note this option still disables various other options such as tscale, invert
Vector variables in a snapshot that should be rotated. Valid options are: pos, vel, and acc. Exact match required for now. [Default: pos,vel,acc]


For ’normal’ unbarred spiral galaxies the following example shows how to project them into their normaly sky view, taking the sense of rotation into account:

   set pa=170             # M51, use pa=200 for M33
   set inc=22             # M51, use inc=30 for M33
   set sign=1             # M51, use sign=-1 for M33
   set sinc=‘nemoinp "-$sign*$inc"‘
   mkdisk - 1000 sign=$sign |\
      snaprotate - - theta=$sinc,$pa order=yz |\
      snapgrid - velfie.ccd mom=-1
   nds9 velfie.ccd        # view the velocity field using ’ds9’.fi
With sign=1 it will create a counter clockwise (CCW) rotating disk and project it using -$inc,$pa, For a clock-wise (CW) rotating disk $inc,$pa, hence the somewhat awkward looking expressing to compute sinc. An alternative desription could be to allow the inclination to be negative as well (which observers do not do), where inc<0 means CCW, and inc>0 means CW rotation.

Suppose you have a barred galaxy model, bar.dat, with the galactic plane at z=0 and the bar along the y axis ("position angle=0"), and want to project this (such that z=0 will be the sky plane, and the positive z-axis pointed towards the observer) with given final position angle ($pa), inclination ($inc) and angle from line of nodes to bar ($phi) the following rotations will do the job:

    set pa=39
    set inc=-45
    set phi=-34
    snaprotate bar.dat n7476.dat "atand(tand($phi)/cosd($inc)),$inc,$pa"
    snapplot n7476 psize="z>0?0.03:0.0"
where psize was choosen such that ‘‘near’’ (z>0) particles were plotted a bit bigger to accentuate the near side of the model. Flipping the sign if $inc will flip the near and far side.


rotation    dPA_near    J_z    sign(J_z)    sinc
CW    +90    away    < 0    inc
CCW    -90    towards    > 0    -inc


Another common way to describe motion (e.g. in an aircraft, robotics) is the Yaw-Pitch-Roll (RPY) convention.

See Also

snapshift(1NEMO) , snapscale(1NEMO) , snapspin(1NEMO) , snapshot(5NEMO)


Joshua E. Barnes,

Peter Teuben


xx-jan-88    V1.0 original                       JEB
3-oct-88    V2.1 eulerian angles (order=zyz)    PJT
17-feb-89:      V2.1a new get+snap macros redef’s    PJT
27-nov-89:    V2.1b cosmetic defv[]                 PJT
15-nov-90    V3.0 theta is now an array keyword    PJT
1-jun-92    documented the rotation manner bit more precise         PJT
11-jun-92    V4.0 rotation now defined in math sense                 PJT
21-nov-98    V5.0 added tscale= keyword    PJT
18-nov-05    V5.1a added select=, also implemented select=acc    PJT
22-sep-08    V6.0 added spinvector=    PJT
18-jan-22    fix sense of rotation example    PJT

Table of Contents