Additional functions for STORM-1315 Ability to do simple math in numeric edit fields
Support for floor, ceil, modulo. Fixed ABS. Added more constants, SQRT_TWO_PI and SQRT3meow-7.2.2
parent
c47d42d945
commit
e08d1e510a
|
|
@ -62,7 +62,9 @@ LLCalc::LLCalc() : mLastErrorPos(0)
|
|||
(*mConstants)["PI"] = F_PI;
|
||||
(*mConstants)["TWO_PI"] = F_TWO_PI;
|
||||
(*mConstants)["PI_BY_TWO"] = F_PI_BY_TWO;
|
||||
(*mConstants)["SQRT_TWO_PI"] = F_SQRT_TWO_PI;
|
||||
(*mConstants)["SQRT2"] = F_SQRT2;
|
||||
(*mConstants)["SQRT3"] = F_SQRT3;
|
||||
(*mConstants)["DEG_TO_RAD"] = DEG_TO_RAD;
|
||||
(*mConstants)["RAD_TO_DEG"] = RAD_TO_DEG;
|
||||
(*mConstants)["GRAVITY"] = GRAVITY;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ struct LLCalcParser : grammar<LLCalcParser>
|
|||
(str_p("SQRT") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_sqrt)(self,arg1)]) |
|
||||
(str_p("LOG") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_log)(self,arg1)]) |
|
||||
(str_p("EXP") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_exp)(self,arg1)]) |
|
||||
(str_p("ABS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_fabs)(self,arg1)])
|
||||
(str_p("ABS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_fabs)(self,arg1)]) |
|
||||
(str_p("FLR") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_floor)(self,arg1)]) |
|
||||
(str_p("CEIL") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_ceil)(self,arg1)])
|
||||
) >> assert_syntax(ch_p(')'))
|
||||
;
|
||||
|
||||
|
|
@ -118,7 +120,8 @@ struct LLCalcParser : grammar<LLCalcParser>
|
|||
term =
|
||||
power[term.value = arg1] >>
|
||||
*(('*' >> assert_syntax(power[term.value *= arg1])) |
|
||||
('/' >> assert_syntax(power[term.value /= arg1]))
|
||||
('/' >> assert_syntax(power[term.value /= arg1])) |
|
||||
('%' >> assert_syntax(power[term.value = bind(&fmodf)(term.value, arg1)]))
|
||||
)
|
||||
;
|
||||
|
||||
|
|
@ -153,7 +156,9 @@ private:
|
|||
F32 _sqrt(const F32& a) const { return sqrt(a); }
|
||||
F32 _log(const F32& a) const { return log(a); }
|
||||
F32 _exp(const F32& a) const { return exp(a); }
|
||||
F32 _fabs(const F32& a) const { return fabs(a) * RAD_TO_DEG; }
|
||||
F32 _fabs(const F32& a) const { return fabs(a); }
|
||||
F32 _floor(const F32& a) const { return llfloor(a); }
|
||||
F32 _ceil(const F32& a) const { return llceil(a); }
|
||||
|
||||
F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue