From af78b122326d9758bd5be8ed1ac887243ac032bc Mon Sep 17 00:00:00 2001 From: Taylor Howell Date: Mon, 11 Dec 2023 12:45:59 -0600 Subject: [PATCH] updating math nodes to fit the new paradigm (maybe it fixes this nasty suprising bug???) --- .../Math/MultiplyNumber.cs | 19 +++++++---------- .../Function Definitions/Math/Pow.cs | 21 ++++++------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/State Machine/Function Definitions/Math/MultiplyNumber.cs b/State Machine/Function Definitions/Math/MultiplyNumber.cs index 45b4b66..90bc4d9 100644 --- a/State Machine/Function Definitions/Math/MultiplyNumber.cs +++ b/State Machine/Function Definitions/Math/MultiplyNumber.cs @@ -29,24 +29,19 @@ protected override void DefineFunction() Name = nameof(MultiplyNumber); Function = () => { - var x = Parameters["a"]; - var y = Parameters["b"]; - var z = Parameters["out"]; - if (x is VariableDefinition aV && y is VariableDefinition bV && z is VariableDefinition resultV) - { - var b = bV.Value; - var a = aV.Value; + var a = Get("a"); + var b = Get("b"); - Debug.WriteLine($"{a} * {b} = {a * b}"); + var result = a * b; - resultV.Value = a * b; + Debug.WriteLine("a: " + a + " b: " + b + " result: " + result); - return 1; - } + Set("out", result); - return -1; + + return 1; }; } } diff --git a/State Machine/Function Definitions/Math/Pow.cs b/State Machine/Function Definitions/Math/Pow.cs index 2ee968c..af4808f 100644 --- a/State Machine/Function Definitions/Math/Pow.cs +++ b/State Machine/Function Definitions/Math/Pow.cs @@ -29,26 +29,17 @@ protected override void DefineFunction() Name = nameof(PowNumber); Function = () => { - var x = Parameters["a"]; - var y = Parameters["b"]; + var a = Get("a"); + var b = Get("b"); - var z = Parameters["out"]; - if (x is VariableDefinition aV && y is VariableDefinition bV && z is VariableDefinition resultV) - { + var result = (float)Math.Pow(a, b); - var b = bV.Value; - var a = aV.Value; + Debug.WriteLine("a: " + a + " b: " + b + " result: " + result); - var powResult = Math.Pow((double)a, (double)b); + Set("out", result); - Debug.WriteLine($"{a} to the power of {b} = {powResult}"); - - resultV.Value = (decimal)powResult; - return 1; - } - - return -1; + return 1; }; }