implemented direction calculation candidate

master
Soper Aylamo 2021-06-19 18:06:39 -04:00
parent c23e74d43e
commit 2b2a1b878e
1 changed files with 5 additions and 11 deletions

View File

@ -21,26 +21,20 @@ public class ArtyMath {
/**
* Calculates angle from east of the vector.
* Uses Minecraft coordinate styling for angle measures
* e.g. pi/2 is south (+z) and 3pi/2 is north (-z)
* @param vector Vector to calculate angle from
* @return Angle from east in radians
*/
public static double calculateDirection(Vector vector){
vector.setY(0);
Vector eastVector = new Vector(1,0,0);
return eastVector.angle(vector);
}
public static double calculateDirectionDOTPRODUCT(Vector vector){
double x = vector.getX();
double z = vector.getZ();
double directionMagnitude = Math.sqrt((x*x)+(z*z));
//dot product is always going to just be the x value
//since the z value for the east vector is 0.
return Math.acos(x/directionMagnitude);
}
public static double calculateDirectionBASICTRIG(Vector vector){
return Math.atan(vector.getZ()/vector.getX());
double angle = Math.acos(x/directionMagnitude);
if(z < 0) angle = 2*Math.PI - angle;
return angle;
}
/**