In the age of steam power, a large central steam engine generated power to rotate a central shaft. A factory would distibute this power by rotating a series of shafts connected by belts throughout the factory. The picture shows a historical steam-driven weaving mill where power is distributed along a series of rotating shafts along the ceiling. Each loom is driven by a belt connected to the top rotating shaft. To start a loom, the operator pulls a lever to engage the drive wheel with the belt. The rusty orange lever on each loom does this in the picture.
In this assignment, you will build a mechanism that shows a 2D visual simulation of this kind of mechanism.
You will build a little mehanism editor.
Create a sketch that allows you to draw a mechanism with the keyboard and/or mouse controlling the parameters. Like the previous recursive tree, you will create a tree-like structure for the parts of your mechanism.
The Root node represents the power wheel, and there will be a number of descendant wheels that are connected by belts to the power wheel. The power wheel drives each of the other wheels via its connecting belts.
Each wheel object in the tree is an instance of a class that has the visual and geometric properties of that wheel. It also has a pointer to each connecting belt.
Each belt in the tree connects a driving wheel to a receiving wheel. Each belt in the tree is an instance of a class that has the visual and geometric properties of that belt.
The mouse and/or keyboard interaction allows you to control some of the appearance of each part.
In this example, my red power wheel in the upper left drives two smaller blue wheels with two belts:
one to the right and one below.
The left blue wheel in turn drives the two small green wheels with two belts.
There are 5 wheel objects that are connected by 4 belt objects in my mechanism.
You need to create a structure that stores info about the current mechanical part,
and has pointers/references to child instances.
You need to store information about the bounding box of each drawable
part of the mechanism so that you can select it and edit it.
You will need to use PVectors for this, because PVector allows you to do things like
PVector v1 = new PVector( 10.0, 5.0 );
v1.rotate( HALF_PI );
With a wheel selected, you should have a little control panel in your editor to adjust the appearance of it. Appearance could mean color or radius, or anything suitable.
You should spend a little time on the appearance of the mechanism, because we want you to be able to show your mechanism off at the end of the term.
This assignment requires that you draw each belt connecting one wheel to another.
The simplest geometry for this a pair of lines that are the tangent lines between
the two circles.
You can use this webpage
to create the formula that computes the tangent points. Draw a line that connects the tangent points
on each circle.
In my mechanism, I used the outer tangent points.
Note that the formula for wheels of the same radius is different than for wheels of different radii.
Either make sure all your radii are different, or have your code conditionally use the proper formula.
You can use our solution to Assignment 2 to build your mechanism.