+ 2

The second hand of clock vibrates

How to fix it? I tried all possible solutions https://code.sololearn.com/WeNMisS0YyH9/?ref=app

6th Nov 2021, 1:14 PM
Sarthak
Sarthak - avatar
3 Respuestas
+ 5
I made some amendments around line 58. The main issue here is the conditions you use to decide whether to draw or not draw the dots. The original approach is to not draw the line if it goes out of bounds of the threshold. This works, but since we are comparing floating point values, the resulting 'edge' is inconsistent, giving the illusion that the line 'vibrates'. The alternate approach is to coerce gx into the limits of the threshold, allowing for a consistent edge. https://code.sololearn.com/WnN51O571ht3/?ref=app
6th Nov 2021, 1:38 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Sarthak 🇳🇵 I tried to understand how you made the boundaries, then saw the comparisons you used. It was just a lucky guess and some trial-and-error in the end, which turned out to be the root cause. I also tried flooring the variables to get rid of the float comparisons, but that resulted in pixelated curves. :D
6th Nov 2021, 2:06 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Cool, how did you figure it out? I'd have spent few hours debugging it.
6th Nov 2021, 1:56 PM
Sarthak
Sarthak - avatar