helix-toolkit icon indicating copy to clipboard operation
helix-toolkit copied to clipboard

GetProjectionMatrix of OrthographicCamera - Matrix not invertible when camera "width" has a high value

Open padael opened this issue 5 years ago • 1 comments

Hello,

i have an issue using an OrthographicCamera. Everything works fine (zoom, pan ...) until camera "width" value gets really high ( e.g. 1000000).

If i add a factor, everything works fine.

(CameraHelper Line 563)

        if (orthographicCamera != null)
        {
            double xscale = 2.0 / orthographicCamera.Width;
            xscale = xscale * 1000;
            double yscale = xscale * aspectRatio;
            double znear = orthographicCamera.NearPlaneDistance * 1000;
            double zfar = orthographicCamera.FarPlaneDistance;

            if (double.IsPositiveInfinity(zfar))
            {
                zfar = znear * 1e5;
            }

            double dzinv = 1000.0 / (znear - zfar);

            var m = new Matrix3D(xscale, 0, 0, 0, 0, yscale, 0, 0, 0, 0, dzinv, 0, 0, 0, znear * dzinv, 1000);
            return m;
        }

Does this have any side effects or is there a better solution? Thanks

padael avatar Nov 11 '20 12:11 padael

Maybe try to scale your scene size, otherwise you may hit the floating point accuracy issue.

holance avatar Nov 12 '20 06:11 holance