Exemple #1
0
        // TODO:
        /// <summary>
        /// Finds the theta and phi to best fit the camera
        /// </summary>
        /// <param name="camera"></param>
        public void FitThetaPhi( OldCamera camera )
        {
            var cameraForward = camera.ViewDirection;
            var cameraUp = camera.UpVector;

            // compute theta:
            // find theta such that the up vector
            // when rotated about groundPlaneUp lies in the 
            // (ground plane forward)-(ground plane up) plane

            // which is just the angle theta it makes projected onto the ground plane
            
            // TODO: define a ground plane point as well?  make it an affine basis...

            // first: take the incoming up vector in world coordinates
            // and transform it into the ground plane basis

            // var gpToWorld = new Matrix3f( GroundPlaneRight, GroundPlaneUp, -GroundPlaneForward );
            var gpToWorld = new Matrix3f( -GroundPlaneForward, GroundPlaneRight, GroundPlaneUp );
            var worldToGP = gpToWorld.Inverse();

            // camera up vector in local coordinates
            var cameraUpGP = worldToGP * cameraUp;

            // compute theta
            var cameraUpGPSpherical = GeometryUtils.RectangularToSpherical( cameraUpGP );

            Theta = cameraUpGPSpherical.y;
            // Phi = MathUtils.PI - cameraUpGPSpherical.z;
            Phi = 0;
        }