From 4dceada8f4380913cfded94a845abf59a6a4d3ee Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 9 Jul 2010 09:35:19 +0000 Subject: 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-ec61d464b74c diff --git a/src/func.cc b/src/func.cc index 9f1b8e7..eb0afcd 100644 --- a/src/func.cc +++ b/src/func.cc @@ -117,6 +117,13 @@ Value builtin_abs(const Context *, const QVector&, const QVector return Value(); } +Value builtin_sign(const Context *, const QVector&, const QVector &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&, const QVector &args) { if (args.size() >= 1 && args[0].type == Value::NUMBER) { @@ -292,6 +299,7 @@ Value builtin_lookup(const Context *, const QVector&, const QVector