Example #1
0
        public void SphericalRadius(out float newRadius, out float zenith, out float azimuth)
        {
            float ex, ey, ez, cx, cy, cz, x, y, z;
            float r; // radius
            float s;

            CCCamera pCamera = m_pTarget.Camera;

            pCamera.GetEyeXyz(out ex, out ey, out ez);
            pCamera.GetCenterXyz(out cx, out cy, out cz);

            x = ex - cx;
            y = ey - cy;
            z = ez - cz;

            r = (float)Math.Sqrt(x * x + y * y + z * z);
            s = (float)Math.Sqrt(x * x + y * y);
            if (s == 0.0f)
            {
                s = float.Epsilon;
            }
            if (r == 0.0f)
            {
                r = float.Epsilon;
            }

            zenith = (float)Math.Acos(z / r);
            if (x < 0)
            {
                azimuth = (float)Math.PI - (float)Math.Sin(y / s);
            }
            else
            {
                azimuth = (float)Math.Sin(y / s);
            }

            newRadius = r / CCCamera.GetZEye();
        }