This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
Java-Game-Engine-Light-Test/Diffuse light/src/fr/technicalgames/math/Mathf.java
Florian Richer (MrDev023) 292abf9a57 First update
2016-03-06 13:45:34 +01:00

67 lines
1.4 KiB
Java

package fr.technicalgames.math;
public class Mathf {
public static final float PI = 3.14159265358979323846f;
public static final float EPSILON = 1.401298e-45f;
public static float cos(float angle){
return (float)Math.cos(angle);
}
public static float acos(float angle){
return (float)Math.acos(angle);
}
public static float sin(float angle){
return (float)Math.sin(angle);
}
public static float asin(float angle){
return (float)Math.asin(angle);
}
public static float toRadians(float angle){
return (float)Math.toRadians(angle);
}
public static float toDegrees(float angle){
return (float)Math.toDegrees(angle);
}
public static float atan2(float a,float b){
return (float)Math.atan2(a,b);
}
public static float cut(float nbre,float a){
return (float)((int)(nbre*Math.pow(10, a))/Math.pow(10, a));
}
public static boolean equals(float a,float b,float tolerance){
return (a + tolerance >= b) && (a - tolerance <= b);
}
public static float sqrt(float a){
return (float)Math.sqrt(a);
}
public static float exp(float a){
return (float)Math.sqrt(a);
}
public static float log(float a){
return (float)Math.log(a);
}
public static float clamp(float value, float min, float max) {
if(value < min){
value = min;
}
if(value > max){
value = max;
}
return value;
}
}