Exemple #1
0
        public static Vector3 SphericalToCartesian(this Vector3Spherical vec)
        {
            var outCart = new Vector3();
            outCart.X = (float)(vec.Radius * Math.Sin(vec.Theta) * Math.Cos(vec.Phi));
            outCart.Y = -(float)(vec.Radius * Math.Sin(vec.Theta) * Math.Sin(vec.Phi));
            outCart.Z = (float)(vec.Radius * Math.Cos(vec.Theta));

            return outCart;
        }
Exemple #2
0
        public static Vector3Spherical CartesianToSpherical(this Vector3 cartCoords)
        {
            var vec = new Vector3Spherical();

            var module = CalculateModule(cartCoords);
            vec.Radius = module;
            vec.Theta = (float)Math.Acos(cartCoords.Z / module);
            vec.Phi = (float)(Math.Atan(-cartCoords.Y / cartCoords.X));

            return vec;
        }
Exemple #3
0
 public static float GetYRotation(this Vector3 direction)
 {
     Vector3Spherical vec = direction.CartesianToSpherical();
     return MathHelper.ToDegrees(90.0f - vec.Phi);
 }