# Documentation

## Working with Frames

Frames form the foundation of multibody modeling. These constructs encode the relative position and orientation of one rigid body with respect to another. In SimMechanics™, every rigid body contains at least one frame.

Consider a double pendulum with two links. Each link has a set of physical properties that affect its dynamic behavior and appearance—geometry, inertia, and color. Yet, none of these properties contain information about the spatial arrangement of the links. To position and orient one link with respect to another, you need frames.

You relate two rigid bodies in space by connecting two frames together. In the double pendulum, you connect the end frame of one link to the end frame of another link using a joint. In turn, each link contains a local reference frame against which you define the two end frames. You can make two frames coincident, translate them, or rotate them with respect to each other.

### Frames

Frames have one origin and three axes. The origin defines the local zero coordinate of the frame. This is the point with respect to which you measure the translational distance between two frames. The axes define the directions in which the components of a 3-D vector are resolved. For example, if you measure the translation vector between two frame origins, you can resolve the vector components along the axes of the base frame. For more information, see Measurement Frames.

### Frame Types

A multibody model generally contains two frame types: global and local. The global frame represents the world. It is inertial and defines absolute rest in a model. In SimMechanics, you represent the global frame with the World Frame block. This block is available in the Frames and Transforms library. The World frame is uniquely defined in every model. You can add multiple World Frame blocks to a model, but they all represent the same frame.

A local frame represents a position and orientation in a rigid body. It can move with respect to the World frame, but not with respect to the rigid body itself. Because it can move with respect to the World frame, a local frame is generally non-inertial. To add a local frame to a rigid body, you use the Rigid Transform block. You can add multiple local frames to a rigid body—to define the position and orientation of joints, to apply an external force or torque, or to sense motion. For more information, see Frame Transformations.

### Frame Transforms

To separate two frames in space, you apply a frame transformation between them. In SimMechanics, two frame transformations are possible: rotation and translation. Rotation changes the relative orientation of two frames. Translation changes their relative position.

Rigid transformations fix spatial relationships for all time. When you rigidly connect two frames, they move as a single unit. They cannot move with respect to each other. In SimMechanics, you apply a rigid transformation with the Rigid Transform block.

 Note:   Frame transformations are important in multibody models. The Rigid Transform block is among the most commonly used in SimMechanics.

You can also relate to frames with a time-varying transformation. In this case, the rotation, translation, or both, can vary as a function of time. One example is the connection between two links in a double-pendulum. Two frames, one on each link, connect with a joint that allows their spatial relationship to vary with time.

To add a time-varying transformation, you use joint blocks. These blocks allow frame transformations to vary with time. The transformations can arise from model dynamics and joint actuation inputs, the latter of which include force, torque, and motion variables.

### Frame Networks

Rigid body subsystems generally have multiple frames. For example, a binary link—one with two connection points—contains two frames, each identifying a connection point. More complex rigid bodies may have yet more frames. In fact, SimMechanics imposes no limit on the number of frames a rigid body can have. You can add as many frames as your application requires.

The set of frames that belong to a rigid body form a frame network. Like other networks, it is often convenient to organize frames hierarchically. You can, for example, organize the frames of a binary link such that its two joint frames are defined with respect to the geometry center frame. In this simple example, the frame network contains two hierarchical levels: a top level containing the geometry center frame, and a lower level containing two joint frames. More complex rigid bodies generally have more hierarchical levels.

The top hierarchical level contains the parent frame. Lower hierarchical levels contain children frames. Children frames can in turn contain their own children frames. All frames in a frame network depend, directly or indirectly, on the parent frame. This dependence exists because the sequence of frame transformations used to define a frame must ultimately reference the parent frame.