devdept

04-14-2010, 07:10 AM

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[14] 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[14] 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;

double sine = Math.Sin(radians);

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

return;

double cotangent = Math.Cos(radians)/sine;

double[] m = new double[16];

m[0] = cotangent/aspect; // m[0][0] = cotangent / aspect;

m[5] = cotangent; // m[1][1] = cotangent;

m[10] = -(zFar + zNear)/deltaZ; // m[2][2] = -(zFar + zNear) / deltaZ;

m[11] = -1; // m[2][3] = -1;

m[14] = -2*zNear*zFar/deltaZ; // m[3][2] = -2 * zNear * zFar / deltaZ;

Trying to fit a drawing with some points at Z coord like 6e+101 we got the perspective projection matrix with -Infinity as m[14] 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[14] 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;

double sine = Math.Sin(radians);

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

return;

double cotangent = Math.Cos(radians)/sine;

double[] m = new double[16];

m[0] = cotangent/aspect; // m[0][0] = cotangent / aspect;

m[5] = cotangent; // m[1][1] = cotangent;

m[10] = -(zFar + zNear)/deltaZ; // m[2][2] = -(zFar + zNear) / deltaZ;

m[11] = -1; // m[2][3] = -1;

m[14] = -2*zNear*zFar/deltaZ; // m[3][2] = -2 * zNear * zFar / deltaZ;