# WORK OUT GUY: The Complete Exercise Routine

## Sarah Hovey, Math 198

### Overview

The purpose of this program is to use VPython to demonstrate exercise. My program demonstrates the use and convenience of using frames within VPython.

### Constructing "Work Out Guy"

The construction of ”work-out guy” was fairly simple, it just involved placing shapes in a coordinate system to resemble a stick figure. I used cylinders to represent the arms, legs, and torso of the body, and I used a sphere to represent the head. As the body was formed and I began to think about movement, I incorporated joints into my original design in order to make the movements seem more realistic. I created spheres to serve as the shoulder, elbow, hip, and knee joints. I also split each of the previous cylinders in to two parts to create upper and lower arms and upper and lower legs. This change would make my work-out guy more flexible and his movements would better resemble the actual movements of the human body.

### Frame Work

After Work Out Guy was created, my next step was to figure out how VPython used frames, and how frames could be used in my program. Frames in VPython serve as a way to group objects together. Frames are treated as objects even though they are not visible, and they have attributes such as a position and an axis. In my program, I created a hierarchy of frames. By using a hierarchy, moving the body is made easier because if one body part in a frame is moved, then all of the other objects also in that frame are moved too.

In my program, the heart frame is the “mother frame,” which means it contains every object in the program. As seen in the chart below, the heart frame is the parent frame for the torso frame, which is the parent frame of the left and right shoulder frames. Creating this hierarchy just means the shoulder frames are dependent on the torso frame, so consequently they are also dependent on the heart frame. Therefore, if the torso frame is moved, both shoulder frames are also moved in the same manner.

After creating the framework for the hierarchy of frames, the next step was positioning each frame to allow the shape of a guy to form. The position assigned to each frame is dependent on the position of its parent frame. In my program, the torso frame has a position of (0,.75,0). Since the position given to the torso frame is dependent on the position of the heart frame, it is located .75 units down the y-axis from the heart frame. Similarly, the left shoulder frame has a position of (-1,-.75,0), which means that it is positioned 1 unit left and .75 units below the torso frame. Once the frames were positioned correctly I could begin placing objects within the frames.

When objects are placed within a frame, they are also dependent on that frame. This can be seen in my program by looking at the shoulder frames. The left shoulder frame contains two objects, the left shoulder and the upper left arm. Since the two objects are in the same frame, when the left shoulder changes position the upper left arm also changes position, and vice versa. Also, if the left shoulder frame is moved up the y-axis one unit, the objects within the frame are also moved up the y-axis one unit.

The process used for positioning the frames is used when positioning objects within the frames. The object’s position is dependent on the position of the frame it is assigned to. For example, if an object’s position is (0,0,0), it is located at the origin of the frame it belongs to. Assigning an object a position gives it a position relative to the frame it is in.

Hierarchy of Frames

### Picking

The picking aspect of my program helps further illustrate the framing system. By using the picking system, you can see how the frames are dependent of one another. In my program, double clicking on an object ”grabs” the frame that the object belongs to. Then, dragging the mouse rotates the frame. The hierarchy of frames can be seen because all objects belonging to the picked frame are rotated, along with any objects belonging to frames dependent on the picked frame. I borrowed this picking system from Baker’s blobby.py.

### Tripod

I implemented a tripod in my program to make it easier to perceive the movements of ”Work Out Guy.” The tripod has a cylinder in the direction of the x-axis and a cone in the direction of the y-axis. The tripod is placed at the origin of each frame that serves as a joint. The only purpose of the tripod is so the orientation of each frame can be seen when the frames begin to rotate. The tripod gives the viewer an axis relative to each joint that can be referenced to judge the degree of rotation.