fBaseXtensions.Navigation.Navigation.FindDirection C# (CSharp) Method

FindDirection() public static method

public static FindDirection ( System.Vector3 vStartLocation, System.Vector3 vTargetLocation, bool inRadian = false ) : float
vStartLocation System.Vector3
vTargetLocation System.Vector3
inRadian bool
return float
        public static float FindDirection(Vector3 vStartLocation, Vector3 vTargetLocation, bool inRadian = false)
        {
            Vector3 startNormalized = vStartLocation;
            startNormalized.Normalize();
            Vector3 targetNormalized = vTargetLocation;
            targetNormalized.Normalize();

            float angle = NormalizeRadian((float)Math.Atan2((vTargetLocation.Y - vStartLocation.Y), (vTargetLocation.X - vStartLocation.X)));
            //MathEx.ToDegrees(NormalizeRadian((float)Math.Atan2(vTargetLocation.Y-vStartLocation.Y, vTargetLocation.X-vStartLocation.X)));

            if (inRadian)
                return angle;
            return MathEx.ToDegrees(angle);
        }