[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] BUG: Detecting rotation at multiples of 90



On, Tue Jun 10, 2008, Charlie Nolan wrote:

> transform.c, 574..586
>     if (!(((int) angle) % 90))
>     {
>         #  (snip) Exact rotation for angles that are multiples of 90.
>     }
> 
> There's a subtle bug here, in that casting to int will eliminate the
> full-precision rotation on every range (90*x, 90*x + 1).  My C-fu is a
> bit weak, but I think that can be fixed by changing the if statement
> to:
>     if ( !( angle % 90.0f ) )

fmodf() or fmod() would be better as % is (to my knowledge) not clearly
defined for floating point types in the C standard. Besides that, I
would agree :-).

Regards
Marcus

Attachment: pgpNoS1nqnJCj.pgp
Description: PGP signature