-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix the 2d drift animation #3816
fix the 2d drift animation #3816
Conversation
I do not see anything wrong with Drift. |
Well, the cast to uint16 prevent the value returned by the sin/cos functions from being negative, so the projection from the screen center can not be symetrical, so the animation wont look like a wheel as advertized (https://raw.githubusercontent.com/scottrbailey/WLED-Utils/master/gifs/FX_164.gif), but as a quarter of a wheel. The tests I did on my screen (0,0 at the top left) displays something wrong, fixed by the cast removal :) |
My own testing on 20x20 and 32x32 (physical) matrices showed no errors and exactly as the advertised image. |
Sorry to take your time but I need to be sure, how are the coordinates mapped on your screens ? const uint16_t maxDim = MAX(cols, rows)/2; => 12, so i from 1 to 12. so the animation will be displayed between [13, 13] and [25, 25], with the center of the wheel at [13, 13]. Am I missing something ? or maybe you are testing the wrong version ? |
Have you tried running it on an actual device? If not, please do. Still, your modification is technically correct and the old one is also correct. While not strictly mathematically it is within the scope of digital math on a CPU (underflows and overflows). |
Sure did, and the fact that it did not work on my hardware pointed me to this correction :) I'm used to microcontroller programming, that's why I want to understand why it can work at all with the current code with your device and not mine. thanks for your time (BTW I work on NRF52) |
Just for consideration: what's the difference between 65535 and -1 in 16 bit integers? None. So if I add 0xFFFE (-2) to 0x0002 I will get exactly the same result if using unsigned or signed integers which is 0. With unsigned the overflow flag will be set, but ignored. If for some reasons your compiler treats |
Thank you. More infos, if you are interested: I see weird results from the casts:
Same with other sizes (8, 32 bits). I dont know if it's normal behavior for this platform. |
That very much depends on the compile implementation. |
Fix a wrong cast that broke the 2D drift animation, add a small optimization to the loop.
close #3814