15 #include "../../bscript/berror.h" 16 #include "../../bscript/bobject.h" 17 #include "../../bscript/impstr.h" 24 using namespace Module;
58 using namespace Bscript;
70 const_pi = acos(
double( -1 ) );
71 const_e = exp(
double( 1 ) );
85 return new Double( sin( x ) );
89 return new BError(
"Invalid parameter type" );
97 return new Double( cos( x ) );
101 return new BError(
"Invalid parameter type" );
109 return new Double( tan( x ) );
113 return new BError(
"Invalid parameter type" );
121 return new Double( asin( x ) );
125 return new BError(
"Invalid parameter type" );
133 return new Double( acos( x ) );
137 return new BError(
"Invalid parameter type" );
145 return new Double( atan( x ) );
149 return new BError(
"Invalid parameter type" );
166 return new Double( pow( x, y ) );
170 return new BError(
"Invalid parameter type" );
183 return new Double( sqrt( x ) );
187 return new BError(
"Invalid parameter type" );
229 for ( std::vector<Bscript::BObjectRef>::iterator itr = value->
ref_arr.begin();
230 itr != value->
ref_arr.end(); ++itr )
241 if ( compare ==
nullptr )
242 compare = bo->impptr();
243 else if ( *( bo->impptr() ) < *compare )
244 compare = bo->impptr();
248 if ( compare !=
nullptr )
249 return ( compare->
copy() );
278 for ( std::vector<BObjectRef>::iterator itr = value->
ref_arr.begin();
279 itr != value->
ref_arr.end(); ++itr )
290 if ( compare ==
nullptr )
291 compare = bo->impptr();
292 else if ( *( bo->impptr() ) >= *compare )
293 compare = bo->impptr();
297 if ( compare !=
nullptr )
298 return ( compare->
copy() );
320 double value =
static_cast<Double*
>( imp )->value();
321 return new Double( fabs( value ) );
325 int value =
static_cast<BLong*
>( imp )->value();
326 return new BLong( labs( value ) );
333 return new BError(
"Invalid parameter type" );
342 return new Double( log10( x ) );
346 return new BError(
"Invalid parameter type" );
354 return new Double( log( x ) );
358 return new BError(
"Invalid parameter type" );
364 return new Double( const_pi );
368 return new Double( const_e );
380 sprintf( buffer,
"%.*g", static_cast<int>( digits ), x );
381 return new String( buffer );
385 return new BError(
"Invalid parameter type" );
393 return new BError(
"Invalid parameter type" );
402 return new Double( ( rad * 180.0 ) / const_pi );
409 return new BError(
"Invalid parameter type" );
417 return new Double( ( deg * const_pi ) / 180.0 );
425 return new Double( ceil( x ) );
429 return new BError(
"Invalid parameter type" );
437 return new Double( floor( x ) );
441 return new BError(
"Invalid parameter type" );
Bscript::BObjectImp * mf_Floor()
Bscript::BObjectImp * mf_ATan()
Bscript::BObjectImp * mf_Sqrt()
std::vector< FunctionDef > FunctionTable
Bscript::BObjectImp * mf_Sin()
Bscript::BObjectImp * mf_Min()
bool getRealParam(unsigned param, double &value)
bool isa(BObjectType type) const
Bscript::BObjectImp * mf_DegToRad()
Bscript::BObjectImp * mf_ConstPi()
Bscript::BObjectImp * mf_ACos()
bool getParam(unsigned param, int &value)
Bscript::BObjectImp * mf_Abs()
virtual BObjectImp * copy() const =0
Bscript::BObjectImp * mf_Cos()
Bscript::BObjectImp * mf_ConstE()
BObjectImp * getParamImp(unsigned param)
Bscript::BObjectImp * mf_Max()
Bscript::BObjectImp * mf_RadToDeg()
Bscript::BObjectImp * mf_Pow()
Bscript::BObjectImp * mf_Ceil()
Bscript::BObjectImp * mf_ASin()
Bscript::BObjectImp * mf_Tan()
Bscript::BObjectImp * mf_FormatRealToString()
Bscript::BObjectImp * mf_Root()
Bscript::BObjectImp * mf_LogE()
Bscript::BObjectImp * mf_Log10()
MathExecutorModule(Bscript::Executor &exec)