Jamoma API  0.6.0.a19
AngleDataspace.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup foundationDataspaceLib
4  *
5  * @brief The #AngleDataspace converts between different measurement untis describing trigonometric angles.
6  *
7  * @details The neutral unit of the angle dataspace is _radian_.
8  *
9  * @authors Nils Peters, Trond Lossius, Tim Place, ...
10  *
11  * @copyright Copyright © 2007 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 "AngleDataspace.h"
18 
19 /***********************************************************************************************/
20 // rad is also the neutral format
21 
22 #define thisTTClass RadianUnit
23 #define thisTTClassName "unit.radian"
24 #define thisTTClassTags "dataspace.unit, angle"
25 
27 TTDataspaceUnit(arguments)
28 {;}
29 
30 RadianUnit::~RadianUnit(){;}
31 
32 
33 void RadianUnit::convertToNeutral(const TTValue& input, TTValue& output)
34 {
35  output = input;
36 }
37 
38 void RadianUnit::convertFromNeutral(const TTValue& input, TTValue& output)
39 {
40  output = input;
41 }
42 
43 
44 #undef thisTTClass
45 #undef thisTTClassName
46 #undef thisTTClassTags
47 
48 /***********************************************************************************************/
49 
50 #define thisTTClass DegreeUnit
51 #define thisTTClassName "unit.degree"
52 #define thisTTClassTags "dataspace.unit, angle"
53 
55 TTDataspaceUnit(arguments)
56 {;}
57 
58 DegreeUnit::~DegreeUnit(){;}
59 
60 
61 void DegreeUnit::convertToNeutral(const TTValue& input, TTValue& output)
62 {
63  output = TTFloat64(input) * kTTDegreesToRadians;
64 }
65 
66 void DegreeUnit::convertFromNeutral(const TTValue& input, TTValue& output)
67 {
68  output = TTFloat64(input) * kTTRadiansToDegrees;
69 }
70 
71 
72 #undef thisTTClass
73 #undef thisTTClassName
74 #undef thisTTClassTags
75 
76 /***********************************************************************************************/
77 
78 #define thisTTClass AngleDataspace
79 #define thisTTClassName "dataspace.angle"
80 #define thisTTClassTags "foundationDataspaceLib, dataspace, angle"
81 
83 {
84  // Create one of each kind of unit, and cache them in a hash
85  registerUnit(TT("unit.radian"), TT("radian"));
86  registerUnit(TT("unit.radian"), TT("rad"));
87  registerUnit(TT("unit.degree"), TT("degree"));
88  registerUnit(TT("unit.degree"), TT("deg"));
89 
90  // Set our neutral unit (the unit through which all conversions are made)
91  neutralUnit = TT("radian");
92 
93  // Now that the cache is created, we can create a set of default units
94  setInputUnit(neutralUnit);
95  setOutputUnit(neutralUnit);
96 }
97 
98 
99 AngleDataspace::~AngleDataspace()
100 {
101  ;
102 }
103 
104 #undef thisTTClass
105 #undef thisTTClassName
106 #undef thisTTClassTags
107 
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from degrees to neutral unit.
The AngleDataspace converts between different measurement untis describing trigonometric angles...
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to degrees.
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
TTFOUNDATION_EXPORT const TTFloat64 kTTRadiansToDegrees
Factor constant for converting radians to degrees.
Definition: TTBase.cpp:32
Specification for the base class of each DataspaceUnit.
TTFOUNDATION_EXPORT const TTFloat64 kTTDegreesToRadians
Factor constant for converting degrees to radians.
Definition: TTBase.cpp:33
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from radians to neutral unit.
TT_OBJECT_CONSTRUCTOR
Constructor macro.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to radians.