private static Ray3D RayFromOrthographicCameraPoint(OrthographicCamera camera, Point point, Size viewSize)
        {
            Point3D     position          = camera.Position;
            Vector3D    lookDirection     = camera.LookDirection;
            Vector3D    upDirection       = camera.UpDirection;
            Transform3D transform         = camera.Transform;
            double      nearPlaneDistance = camera.NearPlaneDistance;
            double      farPlaneDistance  = camera.FarPlaneDistance;
            double      width             = camera.Width;
            Point       normalizedPoint   = CameraRayHelpers.GetNormalizedPoint(point, viewSize);
            double      aspectRatio       = CameraRayHelpers.GetAspectRatio(viewSize);
            double      num1       = width;
            double      num2       = num1 / aspectRatio;
            Point3D     point1     = new Point3D(normalizedPoint.X * (num1 / 2.0), normalizedPoint.Y * (num2 / 2.0), -nearPlaneDistance);
            Vector3D    vector     = new Vector3D(0.0, 0.0, -1.0);
            Matrix3D    viewMatrix = CameraRayHelpers.CreateViewMatrix((Transform3D)null, ref position, ref lookDirection, ref upDirection);

            viewMatrix.Invert();
            Point3D  point3D  = viewMatrix.Transform(point1);
            Vector3D vector3D = viewMatrix.Transform(vector);

            if (transform != null && transform != Transform3D.Identity)
            {
                point3D  = transform.Transform(point3D);
                vector3D = transform.Transform(vector3D);
            }
            return(new Ray3D(point3D, vector3D));
        }
        private static Ray3D RayFromPerspectiveCameraPoint(PerspectiveCamera camera, Point point, Size viewSize)
        {
            Point3D     position          = camera.Position;
            Vector3D    lookDirection     = camera.LookDirection;
            Vector3D    upDirection       = camera.UpDirection;
            Transform3D transform         = camera.Transform;
            double      nearPlaneDistance = camera.NearPlaneDistance;
            double      farPlaneDistance  = camera.FarPlaneDistance;
            double      num1            = camera.FieldOfView * (Math.PI / 180.0);
            Point       normalizedPoint = CameraRayHelpers.GetNormalizedPoint(point, viewSize);
            double      aspectRatio     = CameraRayHelpers.GetAspectRatio(viewSize);
            double      num2            = Math.Tan(num1 / 2.0);
            double      num3            = aspectRatio / num2;
            double      num4            = 1.0 / num2;
            Vector3D    vector          = new Vector3D(normalizedPoint.X / num4, normalizedPoint.Y / num3, -1.0);
            Matrix3D    viewMatrix      = CameraRayHelpers.CreateViewMatrix((Transform3D)null, ref position, ref lookDirection, ref upDirection);

            viewMatrix.Invert();
            Vector3D vector3D = viewMatrix.Transform(vector);
            Point3D  point3D  = position + nearPlaneDistance * vector3D;

            vector3D.Normalize();
            if (transform != null && transform != Transform3D.Identity)
            {
                point3D  = transform.Transform(point3D);
                vector3D = transform.Transform(vector3D);
            }
            return(new Ray3D(point3D, vector3D));
        }