From ce128b944c3241a4a0d79121fba79bdb76fa17ab Mon Sep 17 00:00:00 2001 From: McHorse Date: Fri, 12 Feb 2021 17:41:55 +0000 Subject: [PATCH] Inverse trig functions need to be in degrees --- .../client/particles/molang/MolangParser.java | 8 ++++++++ .../molang/functions/AcosDegrees.java | 18 ++++++++++++++++++ .../molang/functions/AsinDegrees.java | 19 +++++++++++++++++++ .../molang/functions/Atan2Degrees.java | 18 ++++++++++++++++++ .../molang/functions/AtanDegrees.java | 18 ++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 src/main/java/mchorse/blockbuster/client/particles/molang/functions/AcosDegrees.java create mode 100644 src/main/java/mchorse/blockbuster/client/particles/molang/functions/AsinDegrees.java create mode 100644 src/main/java/mchorse/blockbuster/client/particles/molang/functions/Atan2Degrees.java create mode 100644 src/main/java/mchorse/blockbuster/client/particles/molang/functions/AtanDegrees.java diff --git a/src/main/java/mchorse/blockbuster/client/particles/molang/MolangParser.java b/src/main/java/mchorse/blockbuster/client/particles/molang/MolangParser.java index 14c3028eb..2b86b2c1c 100644 --- a/src/main/java/mchorse/blockbuster/client/particles/molang/MolangParser.java +++ b/src/main/java/mchorse/blockbuster/client/particles/molang/MolangParser.java @@ -6,6 +6,10 @@ import mchorse.blockbuster.client.particles.molang.expressions.MolangExpression; import mchorse.blockbuster.client.particles.molang.expressions.MolangMultiStatement; import mchorse.blockbuster.client.particles.molang.expressions.MolangValue; +import mchorse.blockbuster.client.particles.molang.functions.AcosDegrees; +import mchorse.blockbuster.client.particles.molang.functions.AsinDegrees; +import mchorse.blockbuster.client.particles.molang.functions.Atan2Degrees; +import mchorse.blockbuster.client.particles.molang.functions.AtanDegrees; import mchorse.blockbuster.client.particles.molang.functions.CosDegrees; import mchorse.blockbuster.client.particles.molang.functions.SinDegrees; import mchorse.mclib.math.Constant; @@ -39,6 +43,10 @@ public MolangParser() /* Replace radian based sin and cos with degreebased */ this.functions.put("cos", CosDegrees.class); this.functions.put("sin", SinDegrees.class); + this.functions.put("acos", AcosDegrees.class); + this.functions.put("asin", AsinDegrees.class); + this.functions.put("atan", AtanDegrees.class); + this.functions.put("atan2", Atan2Degrees.class); /* Remap functions to be in tact with Molang specification */ this.remap("abs", "math.abs"); diff --git a/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AcosDegrees.java b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AcosDegrees.java new file mode 100644 index 000000000..6db635741 --- /dev/null +++ b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AcosDegrees.java @@ -0,0 +1,18 @@ +package mchorse.blockbuster.client.particles.molang.functions; + +import mchorse.mclib.math.IValue; +import mchorse.mclib.math.functions.trig.Acos; + +public class AcosDegrees extends Acos +{ + public AcosDegrees(IValue[] values, String name) throws Exception + { + super(values, name); + } + + @Override + public double get() + { + return super.get() / Math.PI * 180; + } +} \ No newline at end of file diff --git a/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AsinDegrees.java b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AsinDegrees.java new file mode 100644 index 000000000..c0065a1fc --- /dev/null +++ b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AsinDegrees.java @@ -0,0 +1,19 @@ +package mchorse.blockbuster.client.particles.molang.functions; + +import mchorse.mclib.math.IValue; +import mchorse.mclib.math.functions.Function; +import mchorse.mclib.math.functions.trig.Asin; + +public class AsinDegrees extends Asin +{ + public AsinDegrees(IValue[] values, String name) throws Exception + { + super(values, name); + } + + @Override + public double get() + { + return super.get() / Math.PI * 180; + } +} \ No newline at end of file diff --git a/src/main/java/mchorse/blockbuster/client/particles/molang/functions/Atan2Degrees.java b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/Atan2Degrees.java new file mode 100644 index 000000000..b8e017651 --- /dev/null +++ b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/Atan2Degrees.java @@ -0,0 +1,18 @@ +package mchorse.blockbuster.client.particles.molang.functions; + +import mchorse.mclib.math.IValue; +import mchorse.mclib.math.functions.trig.Atan2; + +public class Atan2Degrees extends Atan2 +{ + public Atan2Degrees(IValue[] values, String name) throws Exception + { + super(values, name); + } + + @Override + public double get() + { + return super.get() / Math.PI * 180; + } +} \ No newline at end of file diff --git a/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AtanDegrees.java b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AtanDegrees.java new file mode 100644 index 000000000..4d2187d22 --- /dev/null +++ b/src/main/java/mchorse/blockbuster/client/particles/molang/functions/AtanDegrees.java @@ -0,0 +1,18 @@ +package mchorse.blockbuster.client.particles.molang.functions; + +import mchorse.mclib.math.IValue; +import mchorse.mclib.math.functions.trig.Atan; + +public class AtanDegrees extends Atan +{ + public AtanDegrees(IValue[] values, String name) throws Exception + { + super(values, name); + } + + @Override + public double get() + { + return super.get() / Math.PI * 180; + } +} \ No newline at end of file