Rotation Matrix and Tilt About X/Y/Z in OpticStudio

This article will give a better insight on how surfaces are positioned in OpticStudio in Sequential and Non-Sequential Mode. It will explain what the rotation matrix and the Tilt About X, Y, Z are, as well as it will answer some related frequently asked questions.

Authored By Michael Cheng, Yuan Chen, and Michael Humphreys

Downloads

global_tilt_xyz_from_glcr_zplm.zip

Introduction

In OpticStudio, we commonly use Tilt About X/Y/Z to rotate Sequential surfaces or Non-sequential objects to a desired orientation.

Tilt About X/Y/Z

In Sequential Mode, Coordinate Break surfaces use Tilt About X/Y/Z to define the orientation of the next surface.
Sequential Mode - Tilts X,Y,Z
In Non-Sequential Mode, all the objects’ orientation are specified by the parameters Tilt About X/Y/Z.
Non Sequential Mode - Tilts X,Y,Z
Theoretically, all the possible orientations can be defined by these three values: Tilt About X/Y/Z.
In other words, a surface or an object can be rotated to any orientation by first rotating about the X-axis and then the Y-axis and finally the Z-axis.

Rotation Matrix

OpticStudio calculates the rotation matrix to convert between the local coordinate and the global coordinate. Here is the relation between the object local coordinates, global coordinates, and the rotation matrix. O is the offset vector. The rotation matrix in OpticStudio describes how the local coordinate can be converted to the global coordinate.

mceclip0.png

The Prescription Data in OpticStudio under Analyze...Reports gives the orientation of a surface or object  with a Rotation Matrix.
The Global Vertex section shows the rotation matrix, R11 to R33, and Tilt About X/Y/Z together.


Prescription Data - Global Vertex
In Non-Sequential Mode, open Analyze > Prescription Data to see the Rotation Matrix for each object:NSC - Rotation Matrix

Converting From Tilt About X/Y/Z to Rotation Matrix

To get the Rotation Matrix from the three Tilt About X/Y/Z values, the Rotation Matrix can be decomposed as a product of three elemental rotation matrices: a Rotation Matrix around X, a Rotation Matrix around Y and a Rotation Matrix around Z.

Conversion

The above formula could describe the rotation matrix created by an extrinsic rotation, first tilt about Z, then tilt about Y, lastly tilt about X. This is equivalent to rotate the system intrinsically first about X, then about Y, lastly about Z. More details are included in the section Intrinsic and Extrinsic Rotations.

Converting From Rotation Matrix to Tilt About X/Y/Z

From Rotation Matrix to Tilt X/Y/Z, the 3 angles can be calculated as below. The 3 angles are for Intrinsic Rotations (see below).

ConversionThe function ATAN2 used in the above picture takes two arguments: the first argument is x and the second argument is y.
The arguments definition for ATAN2 may be different for a programming language to another. Here is a list of the ATAN2 definition for some common programming languages.

Language Function Module/Library
Excel atan2(x, y) Not needed
Python math.atan2(y, x) Import math
MATLAB atan2(y, x) Not needed
C++ atan2(y, x) #include <math.h>
C# Math.Atan2(y, x) using System;
Mathematica ArcTan[x, y] Not needed

Calculating Tilt About X/Y/Z in merit function with ZPL macro

The Rotation Matrix can be displayed in the Merit Function using the GLCR operands. However, right now, there is no single operand to give Tilt About X/Y/Z for arbitrary surfaces. A User-Defined Operand can be written using ZPL to retrieve the Tilts About X/Y/Z.

The attachments of this article contains:

  • A ZPLM User Defined Operand called "ZPL19.zpl". This file can be saved to the folder "{Zemax}\Macros\"
  • An example system that uses this macro in a Merit Function

From given vector (L,M,N) to Tilt About X/Y/Z

Sometimes we are given a vector (L,M,N) representing the object’s z-axis and want to get the corresponding Tilt About X/Y/Z, as shown in the following left picture. We need to mention that only Tilt About X and Tilt About Y are needed for a given (L,M,N) vector. We can use any value for Tilt About Z, which doesn’t change the direction of the local z axis of the object, as in the following right picture.

mceclip1.png

In this case, we simply need to consider (L,M,N) = (R13, R23, R33), where (R13, R23, R33) is the third column in rotation matrix of this object. This relationship is derived by applying the rotation matrix to the local axis vector (0,0,1), as shown below.

mceclip2.png

Then we can calculate Tilt About X/Y as below.

Tilt About X = ATAN2(N,-M)

Tilt About Y = ASIN(L)

mceclip3.png

Another way is to Use Global XYZ Rotation Order.

mceclip4.png

This option allows the system to first tilt about the Z axis, then tilt about Y axis, lastly by X axis. The tilt about Z value changes the Y axis direction, which allows the rotation about new Y’ axis to tilt the Z’ axis to the desired Z” direction.

mceclip5.png

Then we can get Tilt About Z/Y as below.

Tilt About Z= ATAN2(M,L)

Tilt About Y = ACOS(N)

Intrinsic and Extrinsic Rotations

When we say, “Rotate about X-axis, then Y-axis, and finally Z-axis”, there are actually two possible ways to perform:

  • The first method is to always rotate along the original axes, which is called Extrinsic Rotation.
  • The second method is to rotate along the transformed axes, which is the new axes after the previous rotations. This is called Intrinsic Rotation.

OpticStudio uses the rule of Intrinsic Rotations. In other words, after rotating about the X-axis, the Surface/Object will be rotated about the new Y axis and then the new Z axis.

In Sequential mode, the order of the rotations of a Coordinate Break surface can be changed with the Order flag. Flag=0 rotates the surface in order of X->Y->Z in intrinsic manner and Flag=1 is rotates the surface in order of Z->Y->X in intrinsic manner. When a surface/object is rotated using the Extrinsic way,  the order of the rotations are reversed. For example:

  • An Intrinsic Rotation x-y-z (Flag = 0) is same as Extrinsic Rotation z-y-x with the same angles.
  • An Intrinsic Rotation z-y-x (Flag = 1) is same as Extrinsic Rotation z-y-x with the same angles.

Assuming there is one point, under the local coordinate, its coordinate value is [x]L = [xL; yL; zL] and under the global coordinate, its coordinate value is [x]G = [xG; yG; zG].

Without coordinate rotation, the local coordinate and the global coordinate are the same.

Then an extrinsic rotation about Z axis is performed, the coordinate relation becomes:

Rzz) [x]L=[x]G

mceclip6.png

The Rzz) is described as below, it converts all (x,y,z) under the local coordinate to (x,y,z) under the global coordinate.

mceclip7.png

For other axis, we do the same as tilt about Z axis. If we rotate it in order z-y-x in extrinsic rule, the final equation is:

Rxx) Ryy) Rzz) [x]L = [r]G

Rxx) and Ryy) are expressed as below:

mceclip8.png

Then let’s think about the intrinsic rotation. Since the intrinsic rotation tilts the system about the new axis generated by the previous rotation, it is more convenient to write the elemental rotation matrix at the global coordinate side in the equation, as shown below, where the intrinsic rotation about Z axis are taken as an example:

[x]L = Rz(-θz) [r]G

Caution shall be taken here that now we convert the global coordinate onto local one. As the angle tilted is defined as the extrinsic case, the rotation direction is opposite. Therefore, the value of the rotation angle here is -θz

In order to have the same rotation status as the previously mentioned extrinsic example, we tilt the system by the order x->y->z The conversion becomes:

[x]L = Rz(-θz) Ry(-θy) Rx(-θx) [r]G

Then we multiply both sides by Rxx) Ryy) Rzz), we could obtain:

(Rxx) Ryy) Rzz)) [x]L = (Rxx) Ryy) Rzz)) Rz(-θz) Ry(-θy) Rx(-θx) [r]G

As Rzz)) Rz(-θz) = mceclip11.png and the same for Rxx) and Ryy)

We finally have the same as the expression obtained by extrinsic rotation

Rxx) Ryy) Rzz) [x]L = [r]G

Sequential mode also has a tool to switch between local and global coordinates. For more information, see the article How to work in global coordinates in a sequential optical system.

Converting From Rotation Matrix to Extrinsic Tilt About X/Y/Z

The Rotation Matrix may be used to represent one of the following compositions

1. Intrinsic Rotation about axes x-y'-z'', which is same as Extrinsic Rotation about axes z-y-x.

2. Intrinsic Rotation about axes z-y′-x″, which is same as Extrinsic Rotation about axes x-y-z.

We have already explained how to convert the first case to Tilt About X/Y/Z. For the second case, the Tilt About X/Y/Z can be converted from the rotation matrix using the following equations.

Tilt About X = ATAN2( R33, R32)

Tilt About Y = ASIN(-R31)

Tilt About Z = ATAN2(R11, R21)

References

KA-01638

Was this article helpful?
1 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.