Baldwin Computer Science

  1. WEB hosting
  2. Web design and Implementation
  3. Software development
  4. Linux Distributions
  5. Complete Systems
  1. Pay Bill
  2. Help Desk
WEB pages
  1. Bill Baldwin
  2. W. Allan Baldwin
  1. About us
  2. History
  3. Past Projects
  4. Resume
  5. Careers
  6. Contact Us

Units Library

This library has a strictly physical purpose. That is, in handling physical measurements, there is a proliferation of units. This library handles the translation from one unit to another.

In each case, the information is kept internally in a particular unit. Each time the value is referenced, the unit must be given, so the internal representation is not that important.

In addition, operations are defined on the units, so that, for example, if a distance is divided by a time, the result is a velocity. The user doesn't need to worry about translating to the proper units to do the operation, then translating back. It's all done in the classes.

One design decision that needs to be kept in mind is based on the observation that time is really the fourth dimension according to Relativity. I've played with the Lorentz transformations enough to realize that time is, in fact, a true fourth dimension no different than the other three. Therefore, it is possible to measure time in feet, and distance in hours. The difference in the ranges of these units usually makes it desirable not to mix them too much, but measuring time in feet is reasonable for computer cycle times, and measuring distance in years is reasonable for measuring the distance between the stars.

Other methods for these units allow the unit to be set from a string (for example, from a text box), and allow the unit to be formatted in any unit. Also, the names of the units can be extracted.

There is an optional precision, which I am thinking about making mandatory. This keeps track of how accurate a measurement is. When they are used, the precision is kept accurate even through operations are performed on the units. Although this is used in some of the developed software, I'm not sure it has been kept up to date.

The classes are:

This is derived from Units, and represents an acceleration. The units recognized are Gravity and any speed unit divided by a time unit.
This is derived from Units, and represents an angle. The units recognized are Radians, Rotations, Degrees, Minutes, Seconds, and Moon-Diameters. In addition, it can be formatted in Degrees and Minutes, and Degrees, Minutes and Seconds. (Note: a "moon diameter" is about 1/2 a degree, and is the visible size of both the sun and the moon.)
This will allow the user to check the version number of the library. See the Library class in the Utilities library for more details.
This measures a distance. The units recognized are: Millimeters, Centimeters, Meters, Kilometers, Inches, Feet, Yards, Miles, Seconds, Minutes, Hours, Days, Weeks, Years, Decades, Centuries, and Millenia. In addition, the output may be formatted in Feet and Inches, Miles and Feet, Miles, Feet and Inches, or Yards, Feet, Inches.
This is a type intended to supply a consistent dialog for setting the types - that is, the units used and the precisions, etc. It is based on GTK, and needs to be reworked to work properly.
This represents a speed. The units are the Speed of Light, and any distance unit divided by any time unit.
This represents a temperature. This was included despite the fact it wasn't used because it demonstrated that the unit conversion algorithm can become more complicated. The units are: Centigrade, Fahrenheit, Kelvin, and Rankine.
This is identical to the Distance class.
This is the base class of all of the unit classes given It is an abstract class which can be used to refer to the unit when the type of unit is not known.

©2008, Baldwin Computer Science

About us | Legal | Careers | Contact us |  Home4