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()); } }