Jamoma API  0.6.0.a19
SpeedDataspace.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup foundationDataspaceLib
4  *
5  * @brief The #SpeedDataspace converts between different measurement untis describing velocity.
6  *
7  * @details The neutral unit of the speed dataspace is _m/s_.
8  *
9  * @authors Nils Peters, Trond Lossius, Tim Peters, ...
10  *
11  * @copyright Copyright © 2011 by Nils Peters @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "SpeedDataspace.h"
18 
19 
20 #define thisTTClass MilesPerHourUnit
21 #define thisTTClassName "unit.milesPerHour"
22 #define thisTTClassTags "dataspace.unit, speed"
23 
25 TTDataspaceUnit(arguments)
26 {;}
27 
28 MilesPerHourUnit::~MilesPerHourUnit(){;}
29 
31 {
32  output = TTFloat64(input) * 0.44704;
33 }
34 
35 
37 {
38  output = TTFloat64(input) * 2.236936;
39 }
40 
41 
42 #undef thisTTClass
43 #undef thisTTClassName
44 #undef thisTTClassTags
45 
46 /***********************************************************************************************/
47 
48 #define thisTTClass KilometerPerHourUnit
49 #define thisTTClassName "unit.kilometerPerHour"
50 #define thisTTClassTags "dataspace.unit, speed"
51 
53 TTDataspaceUnit(arguments)
54 {;}
55 
56 KilometerPerHourUnit::~KilometerPerHourUnit(){;}
57 
59 {
60  output = TTFloat64(input) / 3.6;
61 }
62 
63 
65 {
66  output = TTFloat64(input) * 3.6;
67 }
68 
69 
70 #undef thisTTClass
71 #undef thisTTClassName
72 #undef thisTTClassTags
73 
74 /***********************************************************************************************/
75 
76 #define thisTTClass FootPerSecondUnit
77 #define thisTTClassName "unit.footPerSecond"
78 #define thisTTClassTags "dataspace.unit, speed"
79 
81 TTDataspaceUnit(arguments)
82 {;}
83 
84 FootPerSecondUnit::~FootPerSecondUnit(){;}
85 
87 {
88  output = TTFloat64(input) * 0.3048;
89 }
90 
91 
93 {
94  output = TTFloat64(input) * 3.2808399;
95 }
96 
97 
98 #undef thisTTClass
99 #undef thisTTClassName
100 #undef thisTTClassTags
101 
102 /***********************************************************************************************/
103 
104 #define thisTTClass KnotUnit
105 #define thisTTClassName "unit.knot"
106 #define thisTTClassTags "dataspace.unit, speed"
107 
109 TTDataspaceUnit(arguments)
110 {;}
111 
112 KnotUnit::~KnotUnit(){;}
113 
114 void KnotUnit::convertToNeutral(const TTValue& input, TTValue& output)
115 {
116  output = TTFloat64(input) * 0.514444; //not exact
117 }
118 
119 
120 void KnotUnit::convertFromNeutral(const TTValue& input, TTValue& output)
121 {
122  output = TTFloat64(input) * 1.943844;//not exact
123 }
124 
125 
126 #undef thisTTClass
127 #undef thisTTClassName
128 #undef thisTTClassTags
129 
130 /***********************************************************************************************/
131 
132 #define thisTTClass MeterPerSecondUnit
133 #define thisTTClassName "unit.meterPerSecond"
134 #define thisTTClassTags "dataspace.unit, speed"
135 
137 TTDataspaceUnit(arguments)
138 {;}
139 
140 MeterPerSecondUnit::~MeterPerSecondUnit(){;}
141 
143 {
144  output = input;
145 }
146 
147 
149 {
150  output = input;
151 }
152 
153 
154 #undef thisTTClass
155 #undef thisTTClassName
156 #undef thisTTClassTags
157 
158 /***********************************************************************************************/
159 
160 #define thisTTClass SpeedDataspace
161 #define thisTTClassName "dataspace.speed"
162 #define thisTTClassTags "foundationDataspaceLib, dataspace, speed"
163 
165 {
166  // Create one of each kind of unit, and cache them in a hash
167  registerUnit(TT("unit.milesPerHour"), TT("mph"));
168  registerUnit(TT("unit.milesPerHour"), TT("mi/h"));
169  registerUnit(TT("unit.kilometerPerHour"), TT("km/h"));
170  registerUnit(TT("unit.kilometerPerHour"), TT("kmph"));
171  registerUnit(TT("unit.meterPerSecond"), TT("m/s"));
172  registerUnit(TT("unit.knot"), TT("kn"));
173  registerUnit(TT("unit.footPerSecond"), TT("ft/s"));
174  registerUnit(TT("unit.footPerSecond"), TT("fps"));
175  // Set our neutral unit (the unit through which all conversions are made)
176  neutralUnit = TT("m/s");
177 
178  // Now that the cache is created, we can create a set of default units
179  setInputUnit(neutralUnit);
180  setOutputUnit(neutralUnit);
181 }
182 
183 
184 SpeedDataspace::~SpeedDataspace()
185 {
186  ;
187 }
188 
189 #undef thisTTClass
190 #undef thisTTClassName
191 #undef thisTTClassTags
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from foot per second to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to knot.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from kilometers per hour to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to foot per second.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from knot to neutral unit.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from miles per hour to neutral unit.
The SpeedDataspace converts between different measurement untis describing velocity.
Specification for the base class of each DataspaceUnit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to miles per hour.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to meters per second.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to radians.
TT_OBJECT_CONSTRUCTOR
Constructor macro.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from meters per second to neutral unit.