**WELCOME TO THE NEW PLATFORM FOR THE OPENSIM DOCUMENTATION**

**Remember to update your bookmarks with our new URL.**

**If you find missing content or broken links, let us know: opensim@stanford.edu **

# Coordinate Systems in OpenSim

Presented by Adam Galloy^{1}, Kayt Frisch PhD^{1}, and Dylan Schmitz^{2}

^{1}Dordt College, ^{2}University of Wisconsin-Madison

Contact: kayt.frisch@dordt.edu

## Introduction

A set of coordinates is only useful if the coordinate system it belongs to is known. In three-dimensional space a coordinate system is defined by an origin and three orthogonal (perpendicular) axes. These axes are conventionally named the x, y, and z axes. Most OpenSim models use a coordinate system defined relative to the human body while it is standing upright. The y-axis points upward, the x-axis points in the direction the subject is facing, and the z-axis points to the subjects right. When using motion capture data with OpenSim, the coordinate system of the motion capture system (often referred to as the lab coordinate system) must be compatible with the OpenSim model’s coordinate system.

Reconciling the rotation of the model coordinate system with the lab coordinates is important since the y-axis determines the direction of the force of gravity in OpenSim. However, the laboratory coordinate system can usually be translated with respect to the model's coordinate system without any problems as long as the coordinates where any forces are applied agree with the coordinates of the 3D marker data.

External forces and moments are usually given in the coordinate system of a the force sensor, such as a force plate, which may be different than the coordinate system used by the markers or model. In this case, the force and moment data must be transformed from the force sensor's coordinate system to agree with the model and marker coordinates.

## Using Preview Experimental Data

Viewing experimental data saved as a .trc file inside of the model coordinate system is an easy way to identify whether or not the lab coordinate system is compatible with the model's coordinate system. See the Previewing Motion Capture (Mocap) Data page for an explanation of how to use the *Preview Experimental Data *feature. By comparing the orientation of the blue experimental markers to the orientation of the model, you can determine whether the coordinate systems match. For example, in the picture below the model's longitudinal axis is aligned with the y-axis of the model coordinate system but the longitudinal axis of the marker data is aligned with the z-axis in the model reference frame. A coordinate transformation is necessary to match the laboratory coordinates to the model coordinates.

Previewing the experimental data also allows the user to visualize the effects of coordinate transformations on the data. This can be helpful for finding the necessary transformations that must be made to the laboratory coordinate systems. The previewed transformations can applied and saved to a new .trc file once the data's coordinate system matches the model's. To fix the coordinate system above the marker data is transformed as shown below. Not every coordinate system discrepancy can be fixed with the *Preview Experimental Data* feature, but the feature can still be a good start to figuring out what transformations need to be applied to a system.

## Simple Coordinate Transformations

A rotation matrix is the most general and powerful way to transform a coordinate system, but for some scenarios simpler math may be used. Below are a couple of common coordinate transformations that can be performed with simpler math.

### Reflecting an Axis

If an axis in the laboratory coordinate system is pointing in the opposite direction as the same axis in the model coordinate system, then reflecting the laboratory axis will correctly reconcile the two coordinate systems. One situation (pictured below) where a reflection can be used is when marker data collected in the laboratory coordinate system is facing the correct direction when placed in the model coordinate space, but markers that should be on the subject's left side are appearing on the right side. No rotation can fix this problem, so the *Preview Experimental Data* feature cannot be used to reconcile the coordinate systems. The z-axis (green) must instead be reflected to put the markers appearing on the subject's left in the model coordinate system on the right side.

The necessary transformation to reconcile the coordiante system in this situation is represented mathematically as ^{model}Z = -^{lab}Z. After applying the transformation, the data appears in the lab coordinate system correctly as shown below.

### Swapping Axes

Sometimes a laboratory axes points in the same direction as another axis in the model coordinate frame. For example, many force plates report an upward reaction force as a positive force along the z-axis. However, OpenSim model's usually require upward forces to be applied along the y-coordinate (since by default gravity is applied as a negative force in the y-direction). The mathematical representation of this coordinate transformation is simply ^{model}Y = ^{lab}Z.

## How to Apply Transformations to Data

Once the proper transformation to reconcile the laboratory coordiante system and the model coordinate system has been found, many options exist for applying the transformations:

- The
*Preview Experimental Data*feature can be used to rotate data as explained above. - Some motion capture systems are capable of exporting motion capture data with transformations applied.
- Scripting tools such as Matlab can read from and write to .trc files to apply the necessary transformations.
- Community created tools for preparing can often perform transformations among many other useful features for preparing data can be found on the Tools for Preparing Motion Data page.

OpenSim is supported by the Mobilize Center , an NIH Biomedical Technology Resource Center (grant P41 EB027060); the Restore Center , an NIH-funded Medical Rehabilitation Research Resource Network Center (grant P2C HD101913); and the Wu Tsai Human Performance Alliance through the Joe and Clara Tsai Foundation. See the People page for a list of the many people who have contributed to the OpenSim project over the years. ©2010-2024 OpenSim. All rights reserved.