public static HyperVector3 Diagonal( Vector3 vec3 )
 {
     HyperVector3 hvec = new HyperVector3();
     hvec.Cascade( vec3 );
     return hvec;
 }
 public static HyperVector3 Normalize( HyperVector3 hvec )
 {
     hvec.Normalize();
     return hvec;
 }
        private Vector3 ComputeCameraPosition( Player p )
        {
            Vector3 playerPos = p.CubePosition;
            Vector3 normal = p.Normal;

            HyperVector3 cubePos = new HyperVector3( playerPos );
            cubePos.Cascade( normal );

            const float sqrt2 = 1.41421356237f;
            Vector3 bias = cubePos.Coalesce(
                v => MathTools.TransformRange( (v / Cube.Scale).Length(), .9f * sqrt2, sqrt2, 0, 1, true ) );

            Vector3 defaultPos = normal * (Cube.CameraDistance - 1) + playerPos;
            //defaultPos = defaultPos.ChangeLength( Cube.CameraDistance );

            HyperVector3 projPos = cubePos.ChangeLength( Cube.CameraDistance );
            projPos.Cascade( defaultPos );

            Vector3 projPosA, projPosB;
            float biasA, biasB;

            #region Project and bias setup
            switch ( normal.LargestComponent() )
            {
            case Vector3Component.X:
                projPosA = projPos.Y;
                projPosB = projPos.Z;
                biasA = bias.Y;
                biasB = bias.Z;
                break;

            case Vector3Component.Y:
                projPosA = projPos.X;
                projPosB = projPos.Z;
                biasA = bias.X;
                biasB = bias.Z;
                break;

            case Vector3Component.Z:
                projPosA = projPos.Y;
                projPosB = projPos.X;
                biasA = bias.Y;
                biasB = bias.X;
                break;

            default:
                throw new EnumException<Vector3Component>( "switch statement" );
            }
            #endregion

            return VectorUtils.Slerp(
                defaultPos.Slerp( projPosA, biasA ),
                defaultPos.Slerp( projPosB, biasB ),
                MathTools.TransformRange( biasB - biasA, -1, 1, 0, 1 ) );
        }