From 58adf467bfa86cc6df6eb8b1b0aada75c317165f Mon Sep 17 00:00:00 2001 From: david Date: Sat, 1 Mar 2003 21:28:51 +0000 Subject: [PATCH] Add a new property to allow raising an axis to a power other than 1 or 2 ( still works as well, and is equivalent to 2). --- src/Main/fg_commands.cxx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 8d5e987b9..7d9958481 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -619,9 +619,28 @@ do_property_scale (const SGPropertyNode * arg) double offset = arg->getDoubleValue("offset", 0.0); double factor = arg->getDoubleValue("factor", 1.0); bool squared = arg->getBoolValue("squared", false); - - if (squared) - setting = (setting < 0 ? -1 : 1) * setting * setting; + int power = arg->getIntValue("power", (squared ? 2 : 1)); + + int sign = (setting < 0 ? -1 : 1); + + switch (power) { + case 1: + break; + case 2: + setting = setting * setting * sign; + break; + case 3: + setting = setting * setting * setting; + break; + case 4: + setting = setting * setting * setting * setting * sign; + break; + default: + setting = pow(setting, power); + if ((power % 2) == 0) + setting *= sign; + break; + } return prop->setDoubleValue((setting + offset) * factor); } -- 2.39.5