Below is a portion of Mouble.Java, one of the source code files, showing the units conversion constants and methods.


import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.lang.*;
import java.util.*;
import java.text.*;

import java.io.*;
import java.net.*;
//import java.math.*;


public class Mouble extends RonEvent 
{

static Toolkit tk = Toolkit.getDefaultToolkit(); // tk.beep(); 

//static final String s_inch = " inch";
//static final String s_mm = " mm";
//static final String s_Mtr = " meter";
//static final String s_mile = " mile";
//static final String s_ast_unt = " AU";
//static final String s_light_y = " L_year";
//static final String s_l_wave = " LWave";
//static final String s_pixel = " pixel";


// Metric morph is metric based with input and output in > char sys_of_units:
// 'M' meters 'm' millimeters 'w' light waves 'p' pixel (no data entry in pixels)
// 'i' inches 'S' miles 'A' astronomical units 'L' light years 
// 'z' other, default then set manually.

/*
Conversions from NIST

1 light year = 9.46073 E+15 meters 

1 mile = 5280 feet

1 foot = .3048 meters

12 inch = 1 foot
1 light wave length at 530 nanometers green = .00053 millimeters

From Fred Johnson

AU = 149,597,870,700 meters

Calculations to be done in centimeters.

'i' inch * 2.54 centimeter

'm' mm * .1 centimeter

'M' meter * 100 centimeter

'S' mile * 160934.4 centimeter

'L' light_year * 9460.73047 * 10000000 * 10000000 centimeter

// default conversion
'w' lightwave * .000053 centimeter aprox.5300 Angstrom, green light.

'A' AU * 149,597,870,700 * 100 centimeter

*/

// Wave length of the light. Default 530 nanometers green light. wave_length PARAM 
// static double wave_length_in_nm = 530;
// static double wave_to_cm_multip = 5300000000;
// Wave length in nm is loaded as a PARAM to over ride default value of 530 nm.
// The value is multiplied to obtain the conversion constant.
// wave_to_cm_multip = wave_length_in_nm * .0000001;

static double inch_to_cm( double inch )
{return( inch * 2.54 );}
static double cm_to_inch( double cm )
{return( cm / 2.54 );}

static double mm_to_cm( double mm )
{return( mm * .1 );}
static double cm_to_mm( double cm )
{return( cm * 10 );}

static double meter_to_cm( double meter )
{return( meter * 100 );}
static double cm_to_meter( double cm )
{return( cm * .01 );}

static double mile_to_cm( double mile )
{return( mile * 160934.4 );}
static double cm_to_mile( double cm )
{return( cm / 160934.4 );}

static double ast_unit_to_cm( double ast_unit )
{return( ast_unit * 1495978.707 * 10000000 );}

static double cm_to_ast_unit( double cm )
{return( cm / ( 1495978.707 * 10000000 ) );}

static double lightyear_to_cm( double light_year )
{return( light_year * 9460.73047 * 10000000 * 10000000 );}
static double cm_to_lightyear( double cm )
{return( cm / ( 9460.73047 * 10000000 * 10000000 ) );}

static double lightwave_to_cm( double light_wave )
{return( light_wave * wave_to_cm_multip );} // {return( light_wave * .000053 );}
static double cm_to_lightwave( double cm )
{return( cm / wave_to_cm_multip );} // {return( cm / .000053 );}

// One way only for pixel.
static double cm_to_pixel( double cm )
{return ( cm / metric_cm[ m_d_btn ] ) * 400;} 




private static char local_focus_of_sys_of_units = 'x';
private static double local_value_cm = 1;
private static double local_value_current_units = -3;
private static Font local_morph_font = null;
private static String s_local_units = null;



... Class continues

 
}  //   End of class Mouble

Note: Text after // is ignored by the compiler until a new line character
is found.(new line)
Text between    /* ignored */   is ignored by the compiler.

 

To obtain this display: right click on a data entry box then use;    Shift    ~

Running the Ronchi / Foucault Java applet in a 'Sun Microsystems' Applet Viewer inside the 'Metrowerks' integrated development environment ( IDE ).

Astronomical Units have been added since this picture was captured.

BACK