 # Fitting a huge drawing

Hi All,

Trying to fit a drawing with some points at Z coord like 6e+101 we got the perspective projection matrix with -Infinity as m value. Is there a way to make a compromise and avoid the program to crash?

Can I replace the -Infinity with a finite value for example?

The real values for m below are:

zNear = 9.62e+171
zFar = 1.30e+172
deltaZ = 3.46e+171

[EDIT] I forgot to mention that other OpenGL based CAD systems can fit this model.

Thanks,

Alberto

``````double radians = fovy/2*Math.PI/180;

double deltaZ = zFar - zNear;

if (deltaZ == 0 || sine == 0 || aspect == 0)

return;

double[] m = new double;

m = cotangent/aspect;        // m = cotangent / aspect;
m = cotangent;               // m = cotangent;
m = -(zFar + zNear)/deltaZ; // m = -(zFar + zNear) / deltaZ;
m = -1;                     // m = -1;
m = -2*zNear*zFar/deltaZ;   // m = -2 * zNear * zFar / deltaZ;
``````

Maybe I can set the m to double.MAX value and compute a new near plane value accordingly?

Thanks,

Alberto

Place bounds on the size and scale the model down by the ratio of the original and adjusted clip.

You can do this around teh eye but you’d be better off bringing all of this into some sane range and compensating.

CAD applications often have scale/unit multipliers somewhere in their system.

Hi dorbie,

I know but in this - quite abusurd and unique - case we were trying simply to avoid a crash.

Do you think that passing +/- double.Max and change near plane position will help?

Thanks,

Alberto