added to math helper
This commit is contained in:
parent
53ca79a784
commit
bbd334284c
1 changed files with 44 additions and 3 deletions
|
@ -7,7 +7,7 @@ import universalelectricity.core.vector.Vector3;
|
|||
public class MathHelper extends net.minecraft.util.MathHelper
|
||||
{
|
||||
/** Generates an array of random numbers
|
||||
*
|
||||
*
|
||||
* @param random - random instance to be used
|
||||
* @param maxNumber - max size of the int to use
|
||||
* @param arraySize - length of the array
|
||||
|
@ -18,7 +18,7 @@ public class MathHelper extends net.minecraft.util.MathHelper
|
|||
}
|
||||
|
||||
/** Generates an array of random numbers
|
||||
*
|
||||
*
|
||||
* @param random - random instance to be used
|
||||
* @param minNumber - smallest random Integer to use. Warning can lead to longer than normal
|
||||
* delay in returns
|
||||
|
@ -54,7 +54,7 @@ public class MathHelper extends net.minecraft.util.MathHelper
|
|||
}
|
||||
|
||||
/** Turns radius and sphere cords into a vector3
|
||||
*
|
||||
*
|
||||
* @param radius - sphere radius
|
||||
* @param inclination -
|
||||
* @param azimuth
|
||||
|
@ -67,4 +67,45 @@ public class MathHelper extends net.minecraft.util.MathHelper
|
|||
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/** Clamps the angles to a min max by adding or subtracting the min max. This way it maintanes
|
||||
* the change in angle in the chance it goes out of bounds */
|
||||
public static float clampAngle(float var, float min, float max)
|
||||
{
|
||||
while (var < min)
|
||||
{
|
||||
var += min;
|
||||
}
|
||||
while (var > max)
|
||||
{
|
||||
var -= max;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
/** Clamps an angle to 360 degree circle */
|
||||
public static float clampAngleTo360(float var)
|
||||
{
|
||||
return MathHelper.clampAngle(var, 0, 360);
|
||||
}
|
||||
|
||||
/** Find the shortest delta change to the angle goal from the current angle */
|
||||
public static float shortestAngleTo360(float angle, float angleGoal)
|
||||
{
|
||||
angle = clampAngleTo360(angle);
|
||||
angleGoal = clampAngleTo360(angleGoal);
|
||||
|
||||
if (angle == angleGoal)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (angle > angleGoal)
|
||||
{
|
||||
return angleGoal - angle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return angle - angleGoal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue