Table of Contents

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.

**in=***snap-file*- Input data is read from
*snap-file*, which must be in snapshot format. **out=***snap-file*- Output data is written to
*snap-file*. **theta=***x-angle*- Angles (in degrees) to
rotate particles about the specified axes in the
**order=**keyword. Up to 3 rotations can be applied. Default: none. **order=***trans-order*- 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. **invert=***invert-flag*- If
**true**, invert specified transformation. Useful for rotating something back to original coordinate system. Default is**false**. **tscale=***t-scale-factor*- 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. **spinvector=***x,y,z*- 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 **select=***vec1,vec2,...*- 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’.fiWith sign=1 it will create a counter clockwise (CCW) rotating disk and project it using

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" zyz snapplot n7476 psize="z>0?0.03:0.0"where

rotationdPA_nearJ_zsign(J_z)sinc CW+90away< 0inc CCW-90towards> 0-inc

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

Peter Teuben

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