33#include <NDEVR/String.h>
34#include <NDEVR/Dictionary.h>
38 template<
class t_type>
68 static t_type
solve(t_type left,
const char op, t_type right)
72 case '+':
return left + right;
73 case '-':
return left - right;
74 case '/':
return left / right;
75 case '*':
return left * right;
76 case '^':
return std::pow(left, right);
77 case '%':
return std::fmod(left, right);
78 case 's':
return std::sin(right);
79 case 'c':
return std::cos(right);
80 case 't':
return std::tan(right);
81 case 'q':
return std::sqrt(right);
82 case '\0':
return right;
95 void add(
char operation, t_type value)
99 part.operation = operation;
143 part.operation = operation;
161 case '^': start = std::pow(start,
m_equation_stack[current_index].value);
break;
162 case '%': start = std::fmod(start,
m_equation_stack[current_index].value);
break;
175 case 's': inner_solve =
sin(inner_solve);
break;
176 case 'c': inner_solve =
cos(inner_solve);
break;
177 case 't': inner_solve =
tan(inner_solve);
break;
178 case 'q': inner_solve =
sqrt(inner_solve);
break;
181 start =
solve(start, lead_operation, inner_solve);
183 case ')':
return start;
184 default:
lib_assert(
false,
"unknown operator");
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
constexpr t_index_type size() const
Definition Buffer.hpp:1461
Definition Dictionary.h:48
void refreshVariables()
Definition Equation.h:59
void add(char operation, t_type value)
Definition Equation.h:95
Equation()
Definition Equation.h:42
static t_type solve(t_type left, const char op, t_type right)
Definition Equation.h:68
void add(char operation, const String &value)
Definition Equation.h:137
void setVariable(const String &var, t_type value)
Definition Equation.h:49
Dictionary< String, t_type > m_variables
Definition Equation.h:190
Buffer< EquationPart > m_equation_stack
Definition Equation.h:191
t_type solve(t_type start, uint04 ¤t_index) const
Definition Equation.h:147
static uint04 getOrderPriority(const char op)
Definition Equation.h:102
void addOrderOfOps(char operation, t_type value)
Definition Equation.h:119
t_type solve() const
Definition Equation.h:86
Dictionary< String, Buffer< uint04 > > m_variable_locations
Definition Equation.h:189
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type tan(const Angle< t_type > &angle)
Definition AngleFunctions.h:182
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type cos(const Angle< t_type > &angle)
Definition AngleFunctions.h:154
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1309
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type sin(const Angle< t_type > &angle)
Definition AngleFunctions.h:113
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
Definition BaseValues.hpp:272
char operation
Definition Equation.h:46
t_type value
Definition Equation.h:47