0

Hey all

I'm writing a rasterizer at the moment, and one of the basic transformations you can perform is rotation. This demands the use of trig functions. However, when rotating a cube, my cube slowly shrinks. Is this s result of loss of accuracy in Math.sin() and Math.cos()? Or is it possibly because I'm casting these values to float, since I use this later for drawing...

Any thoughts?

Thanks, M

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by firstPerson
0

It's because of the float casting. Double is the native floating point type in Java and you should try to maintain your calcs in that if you want to maximize accuracy.

0

>> However, when rotating a cube, my cube slowly shrinks. Is this s result of loss of accuracy in Math.sin() and Math.cos()? Or is it possibly because I'm casting these values to float, since I use this later for drawing...

Rotating the cube has nothing to do with its size!
Sin and cos are accurate enough. Its probably your logic somewhere.
Maybe if you show some code we can help you.
So maybe you are changing its z axis, thus making it appear smaller.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.