[racket] "error: degrees->complex: 360.0"

From: Danny Yoo (dyoo at hashcollision.org)
Date: Mon May 12 19:58:16 EDT 2014

On Mon, May 12, 2014 at 4:11 PM, Sean Kanaley <skanaley at gmail.com> wrote:
> Hello all,
>
> I can't figure this out as I have no function called degrees->complex and it
> occurs only sometimes.  It's always when rotating stuff through the positive
> x axis, as in it's probably related to floating point operations like sin or
> cos near 0 or perhaps integer multiples of 2pi.  So far I believe it has
> only happened rotating clockwise where the error freezes the program with
> slightly negative radians displaying (part of my debug output).
>
> It's possible it's my own bug with a bad sqrt or using NaN or something, but
> then what does the message mean?


You're trying to rotate, but the degrees have to be between 0 and 360 degrees.

    http://docs.racket-lang.org/teachpack/2htdpimage.html#%28def._%28%28lib._2htdp%2Fimage..rkt%29._rotate%29%29

Double check your calls to (rotate) and see that the angle is within
those bounds.

---

Internal comment: The error message appears to arise deep within
htdp-lib/2htdp/private/image-more.rkt.  Unfortunately, the contract
check appears to be done at the private implementation end of things,
rather than at the public function boundary, so the original
questioner is not seeing as helpful of an error message as would be
ideal... Actually, the contract might be wrong.  It says that it has
to be an angle:

    http://docs.racket-lang.org/teachpack/2htdpimage.html#%28def._%28%28lib._2htdp%2Fimage..rkt%29._angle~3f%29%29

but angles aren't restricted to 0-360, even though the internal
implementation really needs it to be within those bounds, according
to:

    http://git.racket-lang.org/plt/blob/HEAD:/pkgs/htdp-pkgs/htdp-lib/2htdp/private/image-more.rkt#l794

Posted on the users mailing list.