KUnitConversion
velocity.cpp
Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "velocity.h" 00021 #include "converter.h" 00022 #include <math.h> 00023 #include <klocale.h> 00024 00025 using namespace KUnitConversion; 00026 00027 class BeaufortConv : public Complex 00028 { 00029 double toDefault(double value) const { return 0.836 * pow(value, 3.0 / 2.0); }; 00030 double fromDefault(double value) const { return pow(value / 0.836, 2.0 / 3.0); }; 00031 }; 00032 00033 Velocity::Velocity() : UnitCategory(VelocityCategory) 00034 { 00035 setName(i18n("Speed")); 00036 setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (velocity)", "%1 %2")); 00037 00038 setDefaultUnit(UP(MeterPerSecond, 1, 00039 i18nc("velocity unit symbol", "m/s"), 00040 i18nc("unit description in lists", "meters per second"), 00041 i18nc("unit synonyms for matching user input", "meter per second;meters per second;m/s;ms"), 00042 ki18nc("amount in units (real)", "%1 meters per second"), 00043 ki18ncp("amount in units (integer)", "%1 meter per second", "%1 meters per second") 00044 )); 00045 U(KilometerPerHour, 0.277778, 00046 i18nc("velocity unit symbol", "km/h"), 00047 i18nc("unit description in lists", "kilometers per hour"), 00048 i18nc("unit synonyms for matching user input", 00049 "kilometer per hour;kilometers per hour;km/h;kmh"), 00050 ki18nc("amount in units (real)", "%1 kilometers per hour"), 00051 ki18ncp("amount in units (integer)", "%1 kilometer per hour", "%1 kilometers per hour") 00052 ); 00053 U(MilePerHour, 0.44704, 00054 i18nc("velocity unit symbol", "mph"), 00055 i18nc("unit description in lists", "miles per hour"), 00056 i18nc("unit synonyms for matching user input", "mile per hour;miles per hour;mph"), 00057 ki18nc("amount in units (real)", "%1 miles per hour"), 00058 ki18ncp("amount in units (integer)", "%1 mile per hour", "%1 miles per hour") 00059 ); 00060 U(FootPerSecond, 0.3048, 00061 i18nc("velocity unit symbol", "ft/s"), 00062 i18nc("unit description in lists", "feet per second"), 00063 i18nc("unit synonyms for matching user input", 00064 "foot per second;feet per second;ft/s;ft/sec;fps"), 00065 ki18nc("amount in units (real)", "%1 feet per second"), 00066 ki18ncp("amount in units (integer)", "%1 foot per second", "%1 feet per second") 00067 ); 00068 U(InchPerSecond, 0.0254, 00069 i18nc("velocity unit symbol", "in/s"), 00070 i18nc("unit description in lists", "inches per second"), 00071 i18nc("unit synonyms for matching user input", 00072 "inch per second;inches per second;in/s;in/sec;ips"), 00073 ki18nc("amount in units (real)", "%1 inches per second"), 00074 ki18ncp("amount in units (integer)", "%1 inch per second", "%1 inches per second") 00075 ); 00076 U(Knot, 0.514444, 00077 i18nc("velocity unit symbol", "kt"), 00078 i18nc("unit description in lists", "knots"), 00079 i18nc("unit synonyms for matching user input", "knot;knots;kt;nautical miles per hour"), 00080 ki18nc("amount in units (real)", "%1 knots"), 00081 ki18ncp("amount in units (integer)", "%1 knot", "%1 knots") 00082 ); 00083 // http://en.wikipedia.org/wiki/Speed_of_sound 00084 U(Mach, 343, 00085 i18nc("velocity unit symbol", "Ma"), 00086 i18nc("unit description in lists", "Mach"), 00087 i18nc("unit synonyms for matching user input", "mach;machs;Ma;speed of sound"), 00088 ki18nc("amount in units (real)", "Mach %1"), 00089 ki18ncp("amount in units (integer)", "Mach %1", "Mach %1") 00090 ); 00091 U(SpeedOfLight, 2.99792458e+08, 00092 i18nc("velocity unit symbol", "c"), 00093 i18nc("unit description in lists", "speed of light"), 00094 i18nc("unit synonyms for matching user input", "speed of light;c"), 00095 ki18nc("amount in units (real)", "%1 speed of light"), 00096 ki18ncp("amount in units (integer)", "%1 speed of light", "%1 speed of light") 00097 ); 00098 // http://en.wikipedia.org/wiki/Beaufort_scale 00099 U(Beaufort, new BeaufortConv(), 00100 i18nc("velocity unit symbol", "bft"), 00101 i18nc("unit description in lists", "Beaufort"), 00102 i18nc("unit synonyms for matching user input", "Beaufort;Bft"), 00103 ki18nc("amount in units (real)", "%1 on the Beaufort scale"), 00104 ki18ncp("amount in units (integer)", "%1 on the Beaufort scale", "%1 on the Beaufort scale") 00105 ); 00106 00107 setMostCommonUnits(QList<int>() << 00108 MeterPerSecond << KilometerPerHour << MilePerHour << Knot << Mach); 00109 }
KDE 4.6 API Reference