On 12/17/2008 12:33 AM, James Turner wrote:
> On 17 Dec 2008, at 01:03, Melchior Franz wrote:
> 
>> + var KT2MPS = 0.5144444444;             # knots to m/s
>> + var MPS2KT = 1 / KT2MPS;
>> +
>>  var LB2KG = 0.45359237;                # pounds to kilogram
>>  var KG2LB = 1 / LB2KG;
> 
> Personally I think all these constants would be easier to read if they  
> were written the same way as the Simgear ones, i.e MPS_TO_KT, NM_TO_M  
> and so on. I understand the logic behind using '2' but it makes the  
> identifiers rather dense.

The tradition in the scientific community in recent decades
has been to do neither of the above.  The best current
practice is called "unit analysis" or the "factor label
method".

The essential idea is to consider _units_ as first-class
algebraically-meaningful objects.

Here are some examples:  Given any self-consistent set of 
base units (usually SI but not necessarily) we can write:
    inch = .0245 * meter;
    foot = 12 * inch;
    mile = 5280 * foot;
    furlong = (1/8) * mile;
    minute = 60 * second;
    hour = 60 * minute;
    day = 24 * hour;
    fortnight = 14 * day;

Then, given that set of units, if you want to express (say) a
velocity that was measured in units of furlongs per fortnight, 
you just say so:
    v = 1.2345 * furlong / fortnight;         [1]

Equation [1] converts _from_ arbitrary units _to_ base units.
If you want to convert the other way around, you use the
reciprocals of the units.

The advantages in terms of concision, precision, and clarity
are rather dramatic.

In this system, you don't need a conversion factor such as
furlong_per_fortnight_2_meter_per_second ... the question
just never comes up, because there are easier ways to do
what needs to be done.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to