mirror of https://github.com/vitalif/openscad
sign() function suggested by Dan Zuras and implemented by Giles Bathgate
git-svn-id: http://svn.clifford.at/openscad/trunk@568 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
a4fc13fee7
commit
b36f7a58dc
|
@ -117,6 +117,13 @@ Value builtin_abs(const Context *, const QVector<QString>&, const QVector<Value>
|
|||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_sign(const Context *, const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args.size() == 1 && args[0].type == Value::NUMBER)
|
||||
return Value((args[0].num<0) ? -1.0 : ((args[0].num>0) ? 1.0 : 0.0));
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value builtin_min(const Context *, const QVector<QString>&, const QVector<Value> &args)
|
||||
{
|
||||
if (args.size() >= 1 && args[0].type == Value::NUMBER) {
|
||||
|
@ -292,6 +299,7 @@ Value builtin_lookup(const Context *, const QVector<QString>&, const QVector<Val
|
|||
void initialize_builtin_functions()
|
||||
{
|
||||
builtin_functions["abs"] = new BuiltinFunction(&builtin_abs);
|
||||
builtin_functions["sign"] = new BuiltinFunction(&builtin_sign);
|
||||
builtin_functions["min"] = new BuiltinFunction(&builtin_min);
|
||||
builtin_functions["max"] = new BuiltinFunction(&builtin_max);
|
||||
builtin_functions["sin"] = new BuiltinFunction(&builtin_sin);
|
||||
|
|
Loading…
Reference in New Issue