Skip to content

Commit

Permalink
Inverse trig functions need to be in degrees
Browse files Browse the repository at this point in the history
  • Loading branch information
mchorse committed Feb 12, 2021
1 parent 7a485a1 commit ce128b9
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit ce128b9

Please sign in to comment.