Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upStrange behavior with rotations #335
Comments
jvoigtlaender
referenced this issue
Aug 6, 2015
Closed
Rotating forms created from shapes over time does not work. #665
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 6, 2015
Contributor
It must have to do with different handling of rotations for "plain" Forms and for Forms that come from Elements. In particular, the black square will rotate if one replaces its definition
blacksquare = filled black (square 400)by
blacksquare = toForm (collage 400 400 [filled black (square 400)])So the question is:
Why does the output rendered for rotate t (toForm (collage 400 400 [ form ])) change as t changes, while the output of rotate t form does not change as t changes (for large t)?
|
It must have to do with different handling of rotations for "plain" blacksquare = filled black (square 400)by blacksquare = toForm (collage 400 400 [filled black (square 400)])So the question is: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Aug 6, 2015
Contributor
I did some profiling and Math.sin is not any slower for large inputs than small ones. However, it's possible ctx.rotate is slow for large angles. You could try theta = form.theta % (Math.PI * 2) and see if that does anything.
|
I did some profiling and |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 6, 2015
Contributor
Yes, though I put the manipulation inside the ctx.rotate-call, to avoid the theta !== 0 test being affected by that modulo computation. See https://github.com/elm-lang/core/pull/338 (closing this here).
|
Yes, though I put the manipulation inside the |
jvoigtlaender
closed this
Aug 6, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thank you for figuring this out, great work! :D |
jvoigtlaender commentedAug 6, 2015
Moved over from elm/compiler#665.
Consider this code:
One would expect that both the black square and Yogi will rotate as time progresses. Both are rotated by the same function with the same argument. But only Yogi rotates.
@mgold observed that the behavior is correct if one replaces
every (20*millisecond)byfoldp (+) 0 (fps 30). So maybe it is an issue with large numbers.