3d matrix problems
Hi,
I''ve made a little program which rotates a small cube. Now I want to make game levels by making the coordinates much bigger.
But when I do that I get screwed up graphics, while the smaal box is rotation and shifting almost perfectly.
Another problem is that the box won''t rotate in degrees, but still in radians or some other unit, while I used the radian 2 degree formula.
I hope someone has an answer to one of these problems. The code is in Pascal.(I know it''s old fashion)
achterlijke_rat@hotmail.com
August 05, 2002 09:51 AM
That sounds like an overflow problem with the scaling up thing.
Are you scaling the matrix or the coordinates? Are you using floating point or fixed point maths?
I think you need to use degrees to radians rather than radians to degrees to get the rotation working in degrees (start with degrees, convert to radians, plug radians into the sin/cos functions, not the other way around).
Are you scaling the matrix or the coordinates? Are you using floating point or fixed point maths?
I think you need to use degrees to radians rather than radians to degrees to get the rotation working in degrees (start with degrees, convert to radians, plug radians into the sin/cos functions, not the other way around).
I''ll try the degree radians math. It''s angle*2*pi/360 right?
I made the coordinates bigger. I used coords of 50 and -50 for the small box. When I used 500 and -500 I get lines that aren''t correct anymore.
How can I solve the problem, because I want to make 3d indoor levels with it.
I made the coordinates bigger. I used coords of 50 and -50 for the small box. When I used 500 and -500 I get lines that aren''t correct anymore.
How can I solve the problem, because I want to make 3d indoor levels with it.
August 05, 2002 11:04 AM
The degrees to radians function is correct.
I use C/C++, but it shouldn''t matter because all maths library funcs take angles in radians, it makes the maths easier for the computer (and mathematicians).
The problem sounds like overflow to me. Are you using integer maths for your coordinates and matrices, and the values overflowing (e.g. in C, if you have two 16 bit signed ints and you multiply 256 by 256 you get 65536 which oveflows and wraps to zero)? Try looking at the variables in the working and non-working version using a debugger. The maths should just produce values 10 times larger in the scaled up case, see where its going wrong.
I use C/C++, but it shouldn''t matter because all maths library funcs take angles in radians, it makes the maths easier for the computer (and mathematicians).
The problem sounds like overflow to me. Are you using integer maths for your coordinates and matrices, and the values overflowing (e.g. in C, if you have two 16 bit signed ints and you multiply 256 by 256 you get 65536 which oveflows and wraps to zero)? Try looking at the variables in the working and non-working version using a debugger. The maths should just produce values 10 times larger in the scaled up case, see where its going wrong.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement