Renderer/src/main/java/electrosphere/util/MathUtils.java
austin e671cda62d
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
hitboxes, ui, bug fixes, network fixes, etc
2024-06-14 13:58:10 -04:00

42 lines
1.0 KiB
Java

package electrosphere.util;
import org.joml.Quaterniond;
import org.joml.Vector3d;
import org.joml.Vector3f;
/**
* Utility functions for doing math
*/
public class MathUtils {
/**
* Gets the origin vector of the engine
* @return The origin vector
*/
public static Vector3d getOriginVector(){
return new Vector3d(0,0,1);
}
/**
* Gets the origin vector of the engine, in Vector3f format
* @return The origin vector
*/
public static Vector3f getOriginVectorf(){
return new Vector3f(0,0,1);
}
/**
* Calculates the quaternion that rotates the origin vector to point from origin to destination
* @param originPoint The point to begin at
* @param destinationPoint The point end at
* @return The quaternion
*/
public static Quaterniond calculateRotationFromPointToPoint(Vector3d originPoint, Vector3d destinationPoint){
return getOriginVector().rotationTo(new Vector3d(originPoint).sub(destinationPoint).normalize(), new Quaterniond());
}
}