From 8b431e116645796adcc5880d5e104b3748746a4d Mon Sep 17 00:00:00 2001 From: Soper Date: Sat, 19 Jun 2021 01:16:54 -0400 Subject: [PATCH] adding new candidates for calculateDirection method replacement --- src/xyz/soper/arty/util/ArtyMath.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/xyz/soper/arty/util/ArtyMath.java b/src/xyz/soper/arty/util/ArtyMath.java index 3c37ee5..8c83435 100644 --- a/src/xyz/soper/arty/util/ArtyMath.java +++ b/src/xyz/soper/arty/util/ArtyMath.java @@ -30,6 +30,19 @@ public class ArtyMath { 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()); + } + /** * Uses the elevation and direction angles given to return a unit vector corresponding to the angles. * @param elevation Angle of elevation in radians