1
Name:
Anonymous
2011-04-20 21:50
const double Pi = 3.14159265358979323846264;
const double TWO_Pi = Pi*2.0;
const double HALF_Pi = Pi/2.0;
const double QUARTER_Pi = Pi/4.0;
const double Deg2Rad = Pi/180.0;
const double Rad2Deg = 180.0/Pi;
const float fDeg2Rad = static_cast(Deg2Rad);
const float fRad2Deg = static_cast(Rad2Deg);
const double OneThird = 1.0/3.0;
const double One3point6th = 1.0/3.6;
const double OneTwelfth = 1.0/12.0;
const double OneThirtysixth = 1.0/36.0;
const double One1760th = 1.0/1760;
const double One5280th = 1.0/5280;
const double One63360th = 1.0/63360.0;
const double One25Pt4th = 1.0/25.4; // 0.0393700787401575 mm -> inches
const double One2Pt54th = 1.0/2.54; // 0.393700787401575 cm -> inches
const double OnePt0254th = 1.0/0.0254; // 39.3700787401575 m -> inches
const double OnePt0000254th = 1.0/0.0000254; // 39370.0787401575 km -> inches
const double One2Pt20462262185th= 1.0/2.20462262185; // 0.453592369999748 Lbs-> Kg
const double One304Pt8th = 1.0/304.8; // 0.00328083989501312 mm -> feet
const double One30Pt48th = 1.0/30.48; // 0.0328083989501312 cm -> feet
const double OnePt3048th = 1.0/.3048; // 3.28083989501312 m -> feet
const double OnePt0003048th = 1.0/.0003048; // 3280.83989501312 km -> feet
const double One914Pt4th = 1.0/914.4; // 0.00109361329833771 mm -> yards
const double One91Pt44th = 1.0/91.44; // 0.0109361329833771 cm -> yards
const double OnePt9144th = 1.0/.9144; // 1.09361329833771 m -> yards
const double OnePt0009144th = 1.0/.0009144; // 1093.61329833771 km -> yards
const double One1609344th = 1.0/1609344; // 0.000000621371192237334 mm -> Miles
const double One160934Pt4th = 1.0/160934.4; // 0.00000621371192237334 cm -> Miles
const double One1609Pt344th = 1.0/1609.344; // 0.000621371192237334 m -> Miles
const double One1Pt609344th = 1.0/1.609344; // 0.621371192237334 km -> Miles
const double One4Pt44822th = 1.0/4.44822161525; // 0.224808943100241 Nt -> LbForce
const double OnePt737562th = 1.0/0.7375621493; // 1.35581794828961 FtLbs -> NtM
const double OnePt44704th = 1.0/0.44704; // 2.2369362920544 Mps -> Mph
const double One3Pt785411th = 1.0/3.78541178401; // 0.264172052357451 Liters -> Gallons
inline double Inches2Feet( const double &i ) { return i*OneTwelfth; } // 1/12
inline double Inches2Yards( const double &i ) { return i*OneThirtysixth; } // 1/36
inline double Inches2Miles( const double &i ) { return i*One63360th; } // 1/63360.0
inline double Inches2MM( const double &i ) { return i*25.4; }
inline double Inches2CM( const double &i ) { return i*2.54; }
inline double Inches2Meters( const double &i ) { return i*.0254; }
inline double Inches2KM( const double &i ) { return i*.0000254; }
inline double Feet2Inches( const double &f ) { return f*12.0; }
inline double Feet2Yards( const double &f ) { return f*OneThird; } // 1/3
inline double Feet2Miles( const double &f ) { return f*One5280th; } // 1/5280
inline double Feet2MM( const double &f ) { return f*304.8; }
inline double Feet2CM( const double &f ) { return f*30.48; }
inline double Feet2Meters( const double &f ) { return f*0.3048; }
inline double Feet2KM( const double &f ) { return f*0.0003048; }
inline double Yards2Inches( const double &y ) { return y*36.0; }
inline double Yards2Feet( const double &y ) { return y*3.0; }
inline double Yards2Miles( const double &y ) { return y*One1760th; } // 1/1760.0
inline double Yards2MM( const double &y ) { return y*914.4; }
inline double Yards2CM( const double &y ) { return y*91.44; }
inline double Yards2Meters( const double &y ) { return y*.9144; }
inline double Yards2KM( const double &y ) { return y*.0009144; }
inline double Miles2Inches( const double &mi ) { return mi*63360.0; }
inline double Miles2Feet( const double &mi ) { return mi*5280; }
inline double Miles2Yards( const double &mi ) { return mi*1760.0; }
inline double Miles2MM( const double &mi ) { return mi*1609344.0; }
inline double Miles2CM( const double &mi ) { return mi*160934.4; }
inline double Miles2Meters( const double &mi ) { return mi*1609.344; }
inline double Miles2KM( const double &mi ) { return mi*1.609344; }
inline double MM2CM( const double &mm ) { return mm*.1; }
inline double MM2Meters( const double &mm ) { return mm*.001; }
inline double MM2KM( const double &mm ) { return mm*.000001; }
inline double MM2Inches( const double &mm ) { return mm*One25Pt4th; } // 0.0393700787401575
inline double MM2Feet( const double &mm ) { return mm*One304Pt8th; } // 0.00328083989501312
inline double MM2Yards( const double &mm ) { return mm*One914Pt4th; } // 0.00109361329833771
inline double MM2Miles( const double &mm ) { return mm*One1609344th; } // 0.000000621371192237334
inline double CM2MM( const double &cm ) { return cm*10.0; }
inline double CM2Meters( const double &cm ) { return cm*.01; }
inline double CM2KM( const double &cm ) { return cm*.00001; }
inline double CM2Inches( const double &cm ) { return cm*One2Pt54th; } // 0.393700787401575
inline double CM2Feet( const double &cm ) { return cm*One30Pt48th; } // 0.0328083989501312
inline double CM2Yards( const double &cm ) { return cm*One91Pt44th; } // 0.0109361329833771
inline double CM2Miles( const double &cm ) { return cm*One160934Pt4th; } // 0.00000621371192237334
inline double Meters2MM( const double &m ) { return m*1000.0; }
inline double Meters2CM( const double &m ) { return m*100.0; }
inline double Meters2KM( const double &m ) { return m*.001; }
inline double Meters2Inches( const double &m ) { return m*OnePt0254th; } // 39.3700787401575
inline double Meters2Feet( const double &m ) { return m*OnePt3048th; } // 3.28083989501312
inline double Meters2Yards( const double &m ) { return m*OnePt9144th; } // 1.09361329833771
inline double Meters2Miles( const double &m ) { return m*One1609Pt344th; } // 0.000621371192237334
inline double KM2Meters( const double &km ) { return km*1000.0; }
inline double KM2CM( const double &km ) { return km*100000.0; }
inline double KM2MM( const double &km ) { return km*1000000.0; }
inline double KM2Inches( const double &km ) { return km*OnePt0000254th; } // 39370.0787401575
inline double KM2Feet( const double &km ) { return km*OnePt0003048th; } // 3280.83989501312
inline double KM2Yards( const double &km ) { return km*OnePt0009144th; } // 1093.61329833771
inline double KM2Miles( const double &km ) { return km*One1Pt609344th; } // 0.621371192237334
inline double Kph2Mph( const double &kph ) { return kph*One1Pt609344th; } // 0.621371192237334
inline double Mph2Kph( const double &mph ) { return mph*1.609344; }
inline double Kph2Mps( const double &kph ) { return kph*One3point6th; } // 1/3.6
inline double Mph2Mps( const double &mph ) { return mph*0.44704; }
inline double Fps2Mps( const double &fps ) { return fps*0.3048; }
inline double Mps2Mph( const double &mps ) { return mps*OnePt44704th; } // 2.2369362920544
inline double Mps2Kph( const double &mps ) { return mps*3.6; }
inline double Mps2Fps( const double &mps ) { return mps*OnePt3048th; } // 3.28083989501312
inline double Lbs2Kg( const double &lbs ) { return lbs*One2Pt20462262185th; } // 0.453592369999748
inline double Kg2Lbs( const double &kg ) { return kg*2.20462262185; }
inline double LbForce2Newtons( const double &lbs ) { return lbs*4.44822161525; }
inline double Newtons2LbForce( const double &nt ) { return nt*One4Pt44822th; } // 0.224808943100241
inline double FtLbs2NtMeters( const double &ftlbs ) { return ftlbs*OnePt737562th; } // 1.35581794828961
inline double NtMeters2FtLbs( const double &ntm ) { return ntm*0.7375621493; }
inline double Gallons2Liters( const double &l ) { return l*3.78541178401; }
inline double Liters2Gallons( const double &g ) { return g*One3Pt785411th; } // 0.264172052357451
inline double Radians2Degrees( const double &r ) { return r*Rad2Deg; } // rad*180/Pi
inline double Degrees2Radians( const double &d ) { return d*Deg2Rad; } // deg*Pi/180
inline double Rad2DegreesIfloat( const float &r ) { return double(r*fRad2Deg); } // rad*180/Pi
inline double Deg2RadiansIfloat( const float &d ) { return double(d*fDeg2Rad); } // deg*Pi/180
inline float floatRadians2Degrees(const double &r) { return float(r*Rad2Deg); } // rad*180/Pi
inline float floatDegrees2Radians(const double &d) { return float(d*Deg2Rad); } // deg*Pi/180
inline float floatRad2Degrees( const float &r ) { return r*fRad2Deg; } // rad*180/Pi
inline float floatDeg2Radians( const float &d ) { return d*fDeg2Rad; } // deg*Pi/180
3
Name:
Anonymous
2011-04-21 3:03
Now it's much shorter.
#define Pi 3.14159265358979323846264
#define TWO_Pi Pi*2.0
#define HALF_Pi Pi/2.0
#define QUARTER_Pi Pi/4.0
#define Deg2Rad Pi/180.0
#define Rad2Deg 180.0/Pi
#define fDeg2Rad static_cast(Deg2Rad)
#define fRad2Deg static_cast(Rad2Deg)
#define OneThird 1.0/3.0
#define One3point6th 1.0/3.6
#define OneTwelfth 1.0/12.0
#define OneThirtysixth 1.0/36.0
#define One1760th 1.0/1760
#define One5280th 1.0/5280
#define One63360th 1.0/63360.0
#define One25Pt4th 1.0/25.4// 0.0393700787401575mm -> inches
#define One2Pt54th 1.0/2.54// 0.393700787401575cm -> inches
#define OnePt0254th 1.0/0.0254// 39.3700787401575m -> inches
#define OnePt0000254th 1.0/0.0000254// 39370.0787401575km -> inches
#define One2Pt20462262185th 1.0/2.20462262185// 0.453592369999748Lbs-> Kg
#define One304Pt8th 1.0/304.8// 0.00328083989501312mm -> feet
#define One30Pt48th 1.0/30.48// 0.0328083989501312cm -> feet
#define OnePt3048th 1.0/.3048// 3.28083989501312m -> feet
#define OnePt0003048th 1.0/.0003048// 3280.83989501312km -> feet
#define One914Pt4th 1.0/914.4// 0.00109361329833771mm -> yards
#define One91Pt44th 1.0/91.44// 0.0109361329833771cm -> yards
#define OnePt9144th 1.0/.9144// 1.09361329833771m -> yards
#define OnePt0009144th 1.0/.0009144// 1093.61329833771km -> yards
#define One1609344th 1.0/1609344// 0.000000621371192237334mm -> Miles
#define One160934Pt4th 1.0/160934.4// 0.00000621371192237334cm -> Miles
#define One1609Pt344th 1.0/1609.344// 0.000621371192237334m -> Miles
#define One1Pt609344th 1.0/1.609344// 0.621371192237334km -> Miles
#define One4Pt44822th 1.0/4.44822161525// 0.224808943100241Nt -> LbForce
#define OnePt737562th 1.0/0.7375621493// 1.35581794828961FtLbs -> NtM
#define OnePt44704th 1.0/0.44704// 2.2369362920544Mps -> Mph
#define One3Pt785411th 1.0/3.78541178401// 0.264172052357451Liters -> Gallons
#define Inches2Feet( i )(i*OneTwelfth)// 1/12
#define Inches2Yards( i )(i*OneThirtysixth)// 1/36
#define Inches2Miles( i )(i*One63360th)// 1/63360.0
#define Inches2MM( i )(i*25.4)
#define Inches2CM( i )(i*2.54)
#define Inches2Meters( i )(i*.0254)
#define Inches2KM( i )(i*.0000254)
#define Feet2Inches( f )(f*12.0)
#define Feet2Yards( f )(f*OneThird)// 1/3
#define Feet2Miles( f )(f*One5280th)// 1/5280
#define Feet2MM( f )(f*304.8)
#define Feet2CM( f )(f*30.48)
#define Feet2Meters( f )(f*0.3048)
#define Feet2KM( f )(f*0.0003048)
#define Yards2Inches( y )(y*36.0)
#define Yards2Feet( y )(y*3.0)
#define Yards2Miles( y )(y*One1760th)// 1/1760.0
#define Yards2MM( y )(y*914.4)
#define Yards2CM( y )(y*91.44)
#define Yards2Meters( y )(y*.9144)
#define Yards2KM( y )(y*.0009144)
#define Miles2Inches( mi )(mi*63360.0)
#define Miles2Feet( mi )(mi*5280)
#define Miles2Yards( mi )(mi*1760.0)
#define Miles2MM( mi )(mi*1609344.0)
#define Miles2CM( mi )(mi*160934.4)
#define Miles2Meters( mi )(mi*1609.344)
#define Miles2KM( mi )(mi*1.609344)
#define MM2CM( mm )(mm*.1)
#define MM2Meters( mm )(mm*.001)
#define MM2KM( mm )(mm*.000001)
#define MM2Inches( mm )(mm*One25Pt4th)// 0.0393700787401575
#define MM2Feet( mm )(mm*One304Pt8th)// 0.00328083989501312
#define MM2Yards( mm )(mm*One914Pt4th)// 0.00109361329833771
#define MM2Miles( mm )(mm*One1609344th)// 0.000000621371192237334
#define CM2MM( cm )(cm*10.0)
#define CM2Meters( cm )(cm*.01)
#define CM2KM( cm )(cm*.00001)
#define CM2Inches( cm )(cm*One2Pt54th)// 0.393700787401575
#define CM2Feet( cm )(cm*One30Pt48th)// 0.0328083989501312
#define CM2Yards( cm )(cm*One91Pt44th)// 0.0109361329833771
#define CM2Miles( cm )(cm*One160934Pt4th)// 0.00000621371192237334
#define Meters2MM( m )(m*1000.0)
#define Meters2CM( m )(m*100.0)
#define Meters2KM( m )(m*.001)
#define Meters2Inches( m )(m*OnePt0254th)// 39.3700787401575
#define Meters2Feet( m )(m*OnePt3048th)// 3.28083989501312
#define Meters2Yards( m )(m*OnePt9144th)// 1.09361329833771
#define Meters2Miles( m )(m*One1609Pt344th)// 0.000621371192237334
#define KM2Meters( km )(km*1000.0)
#define KM2CM( km )(km*100000.0)
#define KM2MM( km )(km*1000000.0)
#define KM2Inches( km )(km*OnePt0000254th)// 39370.0787401575
#define KM2Feet( km )(km*OnePt0003048th)// 3280.83989501312
#define KM2Yards( km )(km*OnePt0009144th)// 1093.61329833771
#define KM2Miles( km )(km*One1Pt609344th)// 0.621371192237334
#define Kph2Mph( kph )(kph*One1Pt609344th)// 0.621371192237334
#define Mph2Kph( mph )(mph*1.609344)
#define Kph2Mps( kph )(kph*One3point6th)// 1/3.6
#define Mph2Mps( mph )(mph*0.44704)
#define Fps2Mps( fps )(fps*0.3048)
#define Mps2Mph( mps )(mps*OnePt44704th)// 2.2369362920544
#define Mps2Kph( mps )(mps*3.6)
#define Mps2Fps( mps )(mps*OnePt3048th)// 3.28083989501312
#define Lbs2Kg( lbs )(lbs*One2Pt20462262185th)// 0.453592369999748
#define Kg2Lbs( kg )(kg*2.20462262185)
#define LbForce2Newtons( lbs )(lbs*4.44822161525)
#define Newtons2LbForce( nt )(nt*One4Pt44822th)// 0.224808943100241
#define FtLbs2NtMeters( ftlbs )(ftlbs*OnePt737562th)// 1.35581794828961
#define NtMeters2FtLbs( ntm )(ntm*0.7375621493)
#define Gallons2Liters( l )(l*3.78541178401)
#define Liters2Gallons( g )(g*One3Pt785411th)// 0.264172052357451
#define Radians2Degrees( r )(r*Rad2Deg)// rad*180/Pi
#define Degrees2Radians( d )(d*Deg2Rad)// deg*Pi/180
#define Rad2DegreesIfloat( r )(double(r*fRad2Deg))// rad*180/Pi
#define Deg2RadiansIfloat( d )(double(d*fDeg2Rad))// deg*Pi/180
#define floatRadians2Degrees(r)(float(r*Rad2Deg))// rad*180/Pi
#define floatDegrees2Radians(d)(float(d*Deg2Rad))// deg*Pi/180
#define floatRad2Degrees( r )(r*fRad2Deg)// rad*180/Pi
#define floatDeg2Radians( d )(d*fDeg2Rad)// deg*Pi/180