From d6284e5e6bba2e2f42ac5d1fc952c73a5c2f5f14 Mon Sep 17 00:00:00 2001 From: clifford Date: Fri, 26 Feb 2010 11:53:32 +0000 Subject: Clifford Wolf: Added abs() function git-svn-id: http://svn.clifford.at/openscad/trunk@454 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 65f073d..e1c06b8 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -4,6 +4,7 @@ OpenSCAD 2010.03 .. ADD STUFF HERE .. o Added functions and statements + - Added abs() function - Added exp(x), log(b, x), log(x) and ln(x) functions - Added minkowski() statement for 3d minkowski sums o Some bugs fixed, maybe some new bugs added diff --git a/src/func.cc b/src/func.cc index ca7a8d4..9f1b8e7 100644 --- a/src/func.cc +++ b/src/func.cc @@ -110,6 +110,13 @@ static double rad2deg(double x) return x; } +Value builtin_abs(const Context *, const QVector&, const QVector &args) +{ + if (args.size() == 1 && args[0].type == Value::NUMBER) + return Value(fabs(args[0].num)); + return Value(); +} + Value builtin_min(const Context *, const QVector&, const QVector &args) { if (args.size() >= 1 && args[0].type == Value::NUMBER) { @@ -284,6 +291,7 @@ Value builtin_lookup(const Context *, const QVector&, const QVector