IvanSanchez / Leaflet.ImageOverlay.Rotated

Displays rotated/slanted image overlays in Leaflet
94 stars 24 forks source link

Rotate image disappears on 90 deg in ie/edge #13

Closed yaelFriedmann closed 5 years ago

yaelFriedmann commented 5 years ago

When I rotate the image in 90 deg the image suddenly disappears

http://ivansanchez.github.io/Leaflet.ImageOverlay.Rotated/demo.html

image

Thanks Yael Friedmann

IvanSanchez commented 5 years ago

Confirmed, not only on IE (firefox as well, chrome seems to be immune), and when control points two and three are aligned vertically. Seems like one of the scale factors is getting too small.

IvanSanchez commented 5 years ago

Thanks for noticing this, @yaelFriedmann - I longed for a reason to get rid of all the weird trigonometry and switch to cleaner linear algebra transformations.

This was an interesting problem, because the conditions were prompting a skew angle close to pi/2 (with a very large cosine, like 1e+18) plus a very small scale factor (close to 1e-18). In theory those would cancel each other, but it seems that some browsers would suffer from floating point rounding errors, and things would become NaN internally. Switching to an affine matrix gets rid of all the trigonometry and the floating point precision loss.

yaelFriedmann commented 5 years ago

Thank you very much for the fast fix!

Yael

frankyfish commented 5 years ago

Wow this helped a lot. Spent couple of days digging into the problem. Working fine in Firefox(68) and Edge(42.17134.1.0) now. Thanks a lot for fix, could you please also update changelog file?

silh commented 5 years ago

Maybe this issue should be reported to Mozilla?

IvanSanchez commented 5 years ago

Maybe this issue should be reported to Mozilla?

I just had the biggest case of dejà vù ever.

https://bugzilla.mozilla.org/show_bug.cgi?id=1203873

IvanSanchez commented 5 years ago

Thanks a lot for fix, could you please also update changelog file?

...and done ;-)