33#include <NDEVR/String.h>
34#include <NDEVR/Dictionary.h>
43 template<
class t_type>
73 static t_type
solve(t_type left,
const char op, t_type right)
77 case '+':
return left + right;
78 case '-':
return left - right;
79 case '/':
return left / right;
80 case '*':
return left * right;
81 case '^':
return std::pow(left, right);
82 case '%':
return std::fmod(left, right);
83 case 's':
return std::sin(right);
84 case 'c':
return std::cos(right);
85 case 't':
return std::tan(right);
86 case 'q':
return std::sqrt(right);
87 case '\0':
return right;
100 void add(
char operation, t_type value)
104 part.operation = operation;
138 part.operation = operation;
156 case '^': start = std::pow(start,
m_equation_stack[current_index].value);
break;
157 case '%': start = std::fmod(start,
m_equation_stack[current_index].value);
break;
170 case 's': inner_solve =
sin(inner_solve);
break;
171 case 'c': inner_solve =
cos(inner_solve);
break;
172 case 't': inner_solve =
tan(inner_solve);
break;
173 case 'q': inner_solve =
sqrt(inner_solve);
break;
176 start =
solve(start, lead_operation, inner_solve);
178 case ')':
return start;
179 default:
lib_assert(
false,
"unknown operator");
#define lib_assert(expression, message)
Definition LibAssert.h:61
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
constexpr t_index_type size() const
Definition Buffer.hpp:823
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Stores in a compressed way, a formula that can be solved. A formula is made of up variables,...
Definition Equation.h:45
void refreshVariables()
Definition Equation.h:64
void add(char operation, t_type value)
Definition Equation.h:100
Equation()
Definition Equation.h:47
static t_type solve(t_type left, const char op, t_type right)
Definition Equation.h:73
void add(char operation, const String &value)
Definition Equation.h:132
void setVariable(const String &var, t_type value)
Definition Equation.h:54
Dictionary< String, t_type > m_variables
Definition Equation.h:185
Buffer< EquationPart > m_equation_stack
Definition Equation.h:186
t_type solve(t_type start, uint04 ¤t_index) const
Definition Equation.h:142
static uint04 getOrderPriority(const char op)
Definition Equation.h:107
void addOrderOfOps(char operation, t_type value)
Definition Equation.h:124
t_type solve() const
Definition Equation.h:91
Dictionary< String, Buffer< uint04 > > m_variable_locations
Definition Equation.h:184
The core String class for the NDEVR API.
Definition String.h:69
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type tan(const Angle< t_type > &angle)
Performs optimized tangent operation on the given angle using pre-computed lookup table for optimal s...
Definition AngleFunctions.h:156
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type cos(const Angle< t_type > &angle)
Performs optimized cosine operation on the given angle using pre-computed lookup table for optimal sp...
Definition AngleFunctions.h:124
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1225
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type sin(const Angle< t_type > &angle)
Performs optimized sine operation on the given angle using pre-computed lookup table for optimal spee...
Definition AngleFunctions.h:79
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
char operation
Definition Equation.h:51
t_type value
Definition Equation.h:52