TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
tb_constants.h
1 
9 #ifndef _TurtleBrains_Constants_h_
10 #define _TurtleBrains_Constants_h_
11 
12 namespace TurtleBrains
13 {
14  namespace Math
15  {
16 
17  static const float kPi(3.14159265358979310f);
18  static const float kTwoPi(kPi * 2.0f);
19 
23  static const float kTolerance(0.00001f);
24 
25  //Conversions
26  const float kPoundsToKilograms(0.45359237f);
27  const float kKilogramsToPounds(1.0f / kPoundsToKilograms);
28  const float kInchesToMeters(0.0254f);
29  const float kMetersToInches(1.0f / kInchesToMeters);
30  const float kFeetToMeters(0.3048f);
31  const float kMetersToFeet(1.0f / kFeetToMeters);
32  const float kMilesToKilometers(1.609344f);
33  const float kKilometersToMiles(1.0f / kMilesToKilometers);
34  const float kFootPoundsToNewtonMeters(0.73756214837f);
36 
37  namespace Convert
38  { //Conversion Functions... Most of these values were found from Google.
39  //Rotations
40 
44  inline float DegreesToRadians(const float degrees) { return degrees * kPi / 180.0f; }
45 
49  inline float RadiansToDegrees(const float radians) { return radians * 180.0f / kPi; }
50 
51  //Weights/Mass
52 
56  inline float PoundsToKilograms(const float pounds) { return pounds * kPoundsToKilograms; }
57 
61  inline float KilogramsToPounds(const float kilograms) { return kilograms * kKilogramsToPounds; }
62 
63  //Distances
64 
68  inline float InchesToMeters(const float inches) { return inches * kInchesToMeters; }
69 
73  inline float FeetToMeters(const float feet) { return feet * kFeetToMeters; };
74 
78  inline float MetersToFeet(const float meters) { return meters * kMetersToFeet; };
79 
80 
84  inline float MilesToKilometers(const float mile) { return mile * kMilesToKilometers; }
85 
89  inline float KilometersToMiles(const float kilometers) { return kilometers * kKilometersToMiles; }
90 
91  //Speeds
92 
96  inline float MileHourToMeterSecond(const float mph) { return mph / 2.2369362920544f; }
97 
101  inline float MeterSecondToMileHour(const float meterSec) { return meterSec * 2.2369362920544f; }
102 
106  inline float KilometerHourToMeterSecond(const float kmh) { return kmh / 3.6f; }
107 
111  inline float MeterSecondToKilometerHour(const float meterSecond) { return meterSecond * 3.6f; }
112 
113  //Torque
114 
118  inline float FootPoundsToNewtonMeters(const float footPounds) { return footPounds / kFootPoundsToNewtonMeters; }
119 
123  inline float NewtonMetersToFootPounds(const float newtonMeters) { return newtonMeters / kNewtonMetersToFootPounds; }
124 
125  //Temperature
126 
130  inline float FahrenheitToCelsius(const float fahrenheit) { return (fahrenheit - 32.0f) / 1.8000f; }
131 
135  inline float CelsiusToFahrenheit(const float celsius) { return (celsius * 1.8000f) + 32.0f; }
136 
137  }; /* namespace Convert */
138  }; /* namespace Math */
139 }; /* namespace TurtleBrains */
140 
141 namespace tbMath = TurtleBrains::Math;
142 
143 #endif /* _TurtleBrains_Constants_h_ */
const float kPoundsToKilograms(0.45359237f)
A constant for the conversion of 1 pound (lb) to 1 kilogram (kg).
Contains objects and functions for dealing with Vector and Matrix math.
const float kKilogramsToPounds(1.0f/kPoundsToKilograms)
A constant for the conversion of 1 kilogram (kg) to 1 pound (lb).
const float kInchesToMeters(0.0254f)
A constant for the distance conversion of 1 inch to 1 meter.
const float kFeetToMeters(0.3048f)
A constant for the distance conversion from 1 foot to 1 meter.
static const float kTolerance(0.00001f)
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
const float kMetersToInches(1.0f/kInchesToMeters)
A constant for the distance conversion of 1 meter to 1 inch.
const float kMilesToKilometers(1.609344f)
A constant for the distance conversion from 1 mile to 1 kilometer.
static const float kTwoPi(kPi *2.0f)
A constant for Pi * 2 stored in a float.
const float kKilometersToMiles(1.0f/kMilesToKilometers)
A constant for the distance conversion from 1 kilometer to 1 mile.
const float kNewtonMetersToFootPounds(1.0f/kFootPoundsToNewtonMeters)
A constant for the torque conversion from Nm to ft-lbs.
const float kFootPoundsToNewtonMeters(0.73756214837f)
A constant for the torque in ft-lbs to Nm.
static const float kPi(3.14159265358979310f)
A constant for the mathematical concept of Pi stored in a float.
const float kMetersToFeet(1.0f/kFeetToMeters)
A constant for the distance conversion from 1 meter to 1 foot.