mirror of https://github.com/vitalif/openscad
Clifford Wolf:
Added pow() function git-svn-id: http://svn.clifford.at/openscad/trunk@128 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
57c3213abb
commit
5312d2fbba
22
func.cc
22
func.cc
|
@ -102,53 +102,60 @@ static double rad2deg(double x)
|
|||
|
||||
Value builtin_sin(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER)
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value(sin(deg2rad(args[0].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_cos(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER)
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value(cos(deg2rad(args[0].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_asin(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER)
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value(rad2deg(asin(args[0].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_acos(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER)
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value(rad2deg(acos(args[0].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_tan(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER)
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value(tan(deg2rad(args[0].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_atan(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER)
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value(rad2deg(atan(args[0].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_atan2(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args[0].type == Value::NUMBER && args[1].type == Value::NUMBER)
|
||||
if (args.size() == 2 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER)
|
||||
return Value(rad2deg(atan2(args[0].num, args[1].num)));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_pow(const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args.size() == 2 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER)
|
||||
return Value(pow(args[0].num, args[1].num));
|
||||
return Value();
|
||||
}
|
||||
|
||||
void initialize_builtin_functions()
|
||||
{
|
||||
builtin_functions["sin"] = new BuiltinFunction(&builtin_sin);
|
||||
|
@ -158,6 +165,7 @@ void initialize_builtin_functions()
|
|||
builtin_functions["tan"] = new BuiltinFunction(&builtin_tan);
|
||||
builtin_functions["atan"] = new BuiltinFunction(&builtin_atan);
|
||||
builtin_functions["atan2"] = new BuiltinFunction(&builtin_atan2);
|
||||
builtin_functions["pow"] = new BuiltinFunction(&builtin_pow);
|
||||
initialize_builtin_dxf_dim();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue