The ObjectBuilder, written in Matlab, is designed to create surfaces in three dimensions, based on user input. When run, the program displays three windows on the screen. The first two are input windows, while the third is a display window. The input windows are used to create two-dimensional shapes, using either of two methods.
The first way in which the user can create a shape is by entering the parametric equations for the shape. There are two fields in each input window, each of which can take in an input string representing a single parametric equation. If the user enters two parametric equations in this way, the correponding parametric shape is drawn in the window. For example, the equations "sin(t)" and "cos(t)" create a circle of radius one.
The other way to create a shape is by entering a series of points. A spline is then fit to the entered points, creating a curve in two dimensions. A spline is a curve which passes through a given set of points, and which has first and second derivative continuity at each of the points. This results in a curve which is very smooth in appearance.
Once the user has entered a shape in each of the two input windows, a three-dimensional surface is created in the display window. This surface is created by sweeping the shape in the first window, which I will refer to as the shape of rotation, along the path described by the shape in the second window, which I will refer to as the path of rotation. In other words, the shape in the second window can be considered as the "spine" of the object when viewed from above, and the shape in the first window can be considered as a cross-section of the object.
As a first example, consider the default setup, in which a circle of radius one is produced in each of the two input windows. As the circle from the first window is rotated along the circle from the second window, it sweeps out a path in the shape of a donut, as shown below.
To understand how this figure is created, it must be understood that each of the two two-dimensional shapes is stored as a certain number of discrete points rather than a continuous curve. That is, each curve is defined by a given number of points through which it passes, and these points are simply connected to create the curve itself. With a fine enough resolution, the shape appears as a smooth curve rather than a number of connected line segments.
For each one of these discrete points p(i) along the path of rotation, an approximate tangent slope is computed by taking the change in y coordinate over the change in x coordinate from point p(i-1) to point p(i+1). The arctangent of this slope is calculated to get the angle theta between the x-axis and the tangent to the curve at point p(i), and a rotation matrix is created using this angle theta. A simple translation matrix is also created according to the position of the point p(i) with respect to the origin. The rotation and translation matrices are combined into one, and applied to the shape of rotation. The result of this procedure is the shape of rotation rotated perpendicular to the tangent of the path of rotation, with its center lying directly on the path of rotation. This is simply the cross section of the final three-dimensional figure at the point p(i). After this is done for all points along the path of rotation (with slight modifications for degenerate or end cases), the Matlab function surfl is applied to the calculated coordinates, creating the figure displayed in the third window.
Now consider a variant of the first example. In this example, the shape of rotation is again a circle, but with a smaller radius. The path of rotation, though, is quite different from that in the first example. This curve, created by a spline fit to a set of points, is easier to think of as a path, since it doesn't connect at the edges. And as can easily be seen in the display window, the small circle has been swept along this path to create a tube in the shape of the path of rotation.
In the third example, the path of rotation is a circle, while the shape of rotation is a spline, which can be considered as an outline of a bottle or vase. As this shape is rotated around the circle, it sweeps out the whole vase, as can be seen in the display window.
Several options are available to the user both in the display window and in the menus. The most interesting of these is the "Scale Body" option in the "Creation Style" menu. This option was originally an incorrect formula, but was later incorporated into the program. Rather than sweeping the shape of rotation along the path of rotation to create a three-dimensional surface, a surface is created by a mutual scaling of the two shapes with respect to eachother. In many cases this creates very bizarre and even physically impossible surfaces, but using the right shapes, it can give very nice results.
The menu labeled shading allows the user to switch from a lit, phong-shaded surface, to a surface with flat shading and highlited edges. The options within the display window allow the user to change the view angle (altitude and azimuth), the size of the axes in which the figure is displayed, and the resolution of the figure.
The ObjectBuilder program consists of five Matlab M-files. Included is source code and explanations of these files.