4 #ifndef _LumiverseORIENTATION_H_
5 #define _LumiverseORIENTATION_H_
8 #include "../LumiverseType.h"
11 #include <unordered_map>
12 #define _USE_MATH_DEFINES
24 { DEGREE,
"degree" }, { RADIAN,
"radian" }
29 {
"degree", DEGREE }, {
"radian", RADIAN }
44 if (u ==
"degree")
return DEGREE;
45 if (u ==
"radian")
return RADIAN;
101 void operator=(
float val);
131 void setVals(
float val,
float def,
float min,
float max);
218 virtual JSONNode
toJSON(
string name);
275 inline bool operator!=(LumiverseOrientation& a, LumiverseOrientation& b) {
280 inline bool operator<(LumiverseOrientation& a, LumiverseOrientation& b) {
281 if (a.getTypeName() !=
"orientation" || b.getTypeName() !=
"orientation")
285 return a.getVal() < b.valAsUnit(a.getUnit());
288 inline bool operator>(LumiverseOrientation& a, LumiverseOrientation& b) {
292 inline bool operator<=(LumiverseOrientation& a, LumiverseOrientation& b) {
296 inline bool operator>=(LumiverseOrientation& a, LumiverseOrientation b) {
301 inline LumiverseOrientation operator+(LumiverseOrientation& lhs,
float rhs) {
302 LumiverseOrientation val = LumiverseOrientation(lhs);
314 inline LumiverseOrientation operator+(LumiverseOrientation lhs, LumiverseOrientation rhs) {
315 LumiverseOrientation val = LumiverseOrientation(lhs);
316 val += rhs.valAsUnit(val.getUnit());
320 inline LumiverseOrientation operator-(LumiverseOrientation& lhs,
float rhs) {
321 LumiverseOrientation val = LumiverseOrientation(lhs);
326 inline LumiverseOrientation operator-(LumiverseOrientation& lhs, LumiverseOrientation& rhs) {
327 LumiverseOrientation val = LumiverseOrientation(lhs);
328 val -= rhs.valAsUnit(val.getUnit());
332 inline LumiverseOrientation operator*(LumiverseOrientation& lhs,
float rhs) {
333 LumiverseOrientation val = LumiverseOrientation(lhs);
338 inline LumiverseOrientation operator*(LumiverseOrientation& lhs, LumiverseOrientation& rhs) {
339 LumiverseOrientation val = LumiverseOrientation(lhs);
340 val *= rhs.valAsUnit(val.getUnit());;
344 inline LumiverseOrientation operator/(LumiverseOrientation& lhs,
float rhs) {
345 LumiverseOrientation val = LumiverseOrientation(lhs);
350 inline LumiverseOrientation operator/(LumiverseOrientation& lhs, LumiverseOrientation& rhs) {
351 LumiverseOrientation val = LumiverseOrientation(lhs);
352 val /= rhs.valAsUnit(val.getUnit());
ORIENTATION_UNIT m_unit
Indicates the type of angle measurement used in the object.
Definition: LumiverseOrientation.h:261
virtual void reset()
Resets the value to the default value.
Definition: LumiverseOrientation.h:184
float valAsUnit(ORIENTATION_UNIT unit)
Returns the value of this orientation with the specified units.
Definition: LumiverseOrientation.h:200
float asUnit(ORIENTATION_UNIT valUnit, float val, ORIENTATION_UNIT targetUnit)
Returns the specified value as the specified unit.
Definition: LumiverseOrientation.cpp:116
This class is a wapper around a variety of different possible data types that might be needed by a De...
Definition: LumiverseType.h:33
void setDefault(float val, ORIENTATION_UNIT unit=DEGREE)
Set the default value for the orientation.
Definition: LumiverseOrientation.h:173
float maxAsUnit(ORIENTATION_UNIT unit)
Returns the max value of the orientation with the specified units.
Definition: LumiverseOrientation.h:205
float getMax()
Get the maximum value.
Definition: LumiverseOrientation.h:155
float m_max
Maximum value for the orientation (default 1.0)
Definition: LumiverseOrientation.h:255
float m_val
the value of this object
Definition: LumiverseOrientation.h:249
float m_default
Default value for this orientation.
Definition: LumiverseOrientation.h:252
float getMin()
Get the minimum value.
Definition: LumiverseOrientation.h:167
float getVal()
Gets the value of the orientation.
Definition: LumiverseOrientation.h:120
void clamp()
Ensures that the value of this float is between min and max.
Definition: LumiverseOrientation.cpp:92
virtual JSONNode toJSON(string name)
Converts the type to a JSON object with the specified name.
Definition: LumiverseOrientation.cpp:32
void setUnit(ORIENTATION_UNIT unit)
Set unit.
Definition: LumiverseOrientation.cpp:75
ORIENTATION_UNIT
Enumeration indicating the type of angular unit stored.
Definition: LumiverseOrientation.h:17
Defines an orientation in Lumiverse.
Definition: LumiverseOrientation.h:61
static unordered_map< string, int > stringToOri
Definition: LumiverseOrientation.h:28
float asPercent()
Returns the value of this orientation as a percentage.
Definition: LumiverseOrientation.cpp:109
LumiverseOrientation(float val=0.0f, ORIENTATION_UNIT unit=DEGREE, float def=0.0f, float max=360.0f, float min=0.0f)
Constructs an orientation, default value is 0.
Definition: LumiverseOrientation.cpp:5
void setVals(float val, float def, float min, float max)
Sets the value of all orientation values except the unit.
Definition: LumiverseOrientation.cpp:66
static unordered_map< int, string > oriToString
Converts orientation to string.
Definition: LumiverseOrientation.h:23
ORIENTATION_UNIT getUnit()
Get the unit.
Definition: LumiverseOrientation.h:143
void setMin(float val, ORIENTATION_UNIT unit=DEGREE)
Set miniumum value.
Definition: LumiverseOrientation.h:161
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
~LumiverseOrientation()
Destroys the orientation.
Definition: LumiverseOrientation.cpp:30
virtual bool isDefault()
Returns true if the value is equal to the default value for the type.
Definition: LumiverseOrientation.cpp:88
float getDefault()
Gets the default value for the orientation.
Definition: LumiverseOrientation.h:179
void setMax(float val, ORIENTATION_UNIT unit=DEGREE)
Set maximum value.
Definition: LumiverseOrientation.h:149
void setValAsPercent(float val)
Sets the value of the LumiverseOrientation proportionally.
Definition: LumiverseOrientation.cpp:103
float defaultAsUnit(ORIENTATION_UNIT unit)
Returns the default value of the orientation with the specified units.
Definition: LumiverseOrientation.h:215
virtual string getTypeName()
Says that this object is an orientation.
Definition: LumiverseOrientation.h:98
virtual string asString()
Returns the value of the LumiverseOrientation as a string.
Definition: LumiverseOrientation.cpp:50
float minAsUnit(ORIENTATION_UNIT unit)
Returns the min value of the orientation with the specified units.
Definition: LumiverseOrientation.h:210
void setVal(float val, ORIENTATION_UNIT unit=DEGREE)
Sets the value of the orientation.
Definition: LumiverseOrientation.h:126
float m_min
Minimum value for the orientation (default 0.0)
Definition: LumiverseOrientation.h:258