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.

In Non-Sequential Mode, all the objects’ orientation are specified by the parameters Tilt About 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.

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.

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

## 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.

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).

The 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.

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.

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

Tilt About X = ATAN2(N,-M)

Tilt About Y = ASIN(L)

Another way is to Use Global XYZ Rotation Order.

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.

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} = [x_{L}; y_{L}; z_{L}] and under the global coordinate, its coordinate value is [x]_{G} = [x_{G}; y_{G}; z_{G}].

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:

R_{z}(θ_{z}) [x]_{L}=[x]_{G}

_{}

The R_{z}(θ_{z}) is described as below, it converts all (x,y,z) under the local coordinate to (x,y,z) under the global coordinate.

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:

R_{x}(θ_{x}) R_{y}(θ_{y}) R_{z}(θ_{z}) [x]_{L} = [r]_{G}

R_{x}(θ_{x}) and R_{y}(θ_{y}) are expressed as below:

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} = R_{z}(-θ_{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} = R_{z}(-θ_{z}) R_{y}(-θ_{y}) R_{x}(-θ_{x}) [r]_{G}

**Then we multiply both sides by R _{x}(θ_{x}) R_{y}(θ_{y}) R_{z}(θ_{z}), we could obtain:**

**(R _{x}(θ_{x}) R_{y}(θ_{y}) R_{z}(θ_{z}))** [x]

_{L}=

**(R**R

_{x}(θ_{x}) R_{y}(θ_{y}) R_{z}(θ_{z}))_{z}(-θ

_{z}) R

_{y}(-θ

_{y}) R

_{x}(-θ

_{x}) [r]

_{G}

As **R _{z}(θ_{z}))**

**R**= and the same for

_{z}(-θ_{z})**R**

_{x}(θ_{x}) and R_{y}(θ_{y})**We finally have the same as the expression obtained by extrinsic rotation**

R_{x}(θ_{x}) R_{y}(θ_{y}) R_{z}(θ_{z}) [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(* R _{33}*,

*R*)

_{32}Tilt About Y = ASIN(-*R _{31}*)

Tilt About Z = ATAN2(R_{11},* R _{21}*)

## References

- More information about the relationships between Intrinsic and Extrinsic can be found here: https://en.wikipedia.org/wiki/Davenport_chained_rotations#Conversion_between_intrinsic_and_extrinsic_rotations

KA-01638

## Comments

Article is closed for comments.