summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-26 11:53:32 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-26 11:53:32 (GMT)
commitd6284e5e6bba2e2f42ac5d1fc952c73a5c2f5f14 (patch)
tree6077ea68d848f470b72888af590daaf0f33e8ac0
parent26cf4309df43667eb763366eb01f873124820d3e (diff)
Clifford Wolf:
Added abs() function git-svn-id: http://svn.clifford.at/openscad/trunk@454 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r--RELEASE_NOTES1
-rw-r--r--src/func.cc8
2 files changed, 9 insertions, 0 deletions
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<QString>&, const QVector<Value> &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<QString>&, const QVector<Value> &args)
{
if (args.size() >= 1 && args[0].type == Value::NUMBER) {
@@ -284,6 +291,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["min"] = new BuiltinFunction(&builtin_min);
builtin_functions["max"] = new BuiltinFunction(&builtin_max);
builtin_functions["sin"] = new BuiltinFunction(&builtin_sin);
contact: Jan Huwald // Impressum