Hi everyone, I’m writing a program that displays the current modelview and projection matrix to a window with glut. My question is what are the extreme values (in essence how many digits) that can be held in a usual matrix? I’ve tried using some extreme frustum values like -20000 20000 left right and saw that the values in the matrix were around -200 so currently I display the values with 3 digits for the number and 5 digits for the decimal numbers. (plus two more digits, one for a leading minus sign and the . symbol of course). The purpose of this program should be to teach how the matrices affect the vertices in the real world. Does anyone see that I might need higher presicions? Thanks in advance.

Hi !

Depends on if you use float or doubles, most OpenGL implementations use 32 bit float internally:

MS provides two floating-point data types, Single and Double. The Single data type requires 4 bytes of memory and can store negative values between -3.402823 x 1038 and -1.401298 x 10-45 and positive values between 1.401298 x 10-45 and 3.402823 x 1038. The Double data type requires 8 bytes of memory and can store negative values between -1.79769313486232 x 10308 and -4.94065645841247 x 10-324 and positive values between 4.94065645841247 x 10-324 and 1.79769313486232 x 10308.

The Single and Double data types are very precise — that is, they make it possible for you to specify extremely small or large numbers. However, these data types are not very accurate because they use floating-point mathematics. Floating-point mathematics has an inherent limitation in that it uses binary digits to represent decimals. Not all the numbers within the range available to the Single or Double data type can be represented exactly in binary form, so they are rounded. Also, some numbers cannot be represented exactly with any finite number of digits — pi, for example, or the decimal resulting from 1/3.

Because of these limitations to floating-point mathematics, you might encounter rounding errors when you perform operations on floating-point numbers. Compared to the size of the value you are working with, the rounding error will be very small. If you do not require absolute accuracy and can afford relatively small rounding errors, the floating-point data types are ideal for representing very small or very large values. On the other hand, if your values must be accurate — for example, if you are working with money values — you should consider one of the scaled integer data types.

Single = about 7 digits, Double = 14 digits.

Mikael

Thanks for the answer but it is not exactly what I’m looking for. Maybe I wasn’t as clear in my first posting. I need to know about the “usual” extremes (or say empirical values). I mean that I don’t want to cover 100% of cases, more like 80-90% of them. What I mean is if for values up until, say 100.000 the frustum produces a matrix with a highest value of -800, I’m ok with that. The application isn’t too important (if you can call teaching unimportant) but I would not want to fall short in like a student wanting to produce a value and the application is not to produce it. Inside the program I use double values and I draw the string on the window with a sprintf and then a custom string function using glut’s font api. Do you think that with a range of -999.99999 to 9999.99999 I am ok for displaying a smooth animation? It’s not a bad idea to try to represent the higher values with e.g. 4.56e-78, I’ll see what can come out of it.

[This message has been edited by moucard (edited 03-16-2004).]

The values in the matrix do not represent the largest values for your x, y, z, or w components for vertices. They represent how the data from a vertex will be converted into world space, then into clip space (or screen space). If you want to find the largest possible element (value) in a matrix, check the OpenGL red book; the frustum and orthographic projection matrices are listed in there near the end. Then, you can compute the largest value yourself.

This may not be much help because I’m not entirely sure what you’re asking for, but I hope this helped a litte. ^^

[This message has been edited by Nychold (edited 03-16-2004).]

Well, while you did not give me an exact answer you pointed in the right direction. I think I can compute the values I want from what I believe I will regard an extreme value for a frustum or a translate command. Thanks!