Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

fix the animation with two positions too close - #8097

Closed
TranThuong wants to merge 1 commit into
mapbox:masterfrom
Mappy:fix_animation_flyto_two_close_points
Closed

TranThuong wants to merge 1 commit into
mapbox:masterfrom
Mappy:fix_animation_flyto_two_close_points

Conversation

@TranThuong

@TranThuong TranThuong commented Feb 17, 2017 •

Copy link
Copy Markdown

Hello,

We have an issue in animating with the method MapboxMap.animateCamera(...), the zoom is from 16 to 7, the center isn't changed. That make the mapbox in the unstable state, the center and the bounding box are NaN. We must restart the application.

After further investigation, we identify the root cause of the problem :
In the class transform.cpp, the method Transform::flyTo cause the issue. If endPoint and startPoint are too close (<1) the following piece of code return "inf" due to "std::sqrt(b * b + 1) - b" equals absolute 0 then "std::log(std::sqrt(b * b + 1) - b);" becomes std::log(0) = -inf

auto r = [=](double i) { /// bᵢ double b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1); return std::log(std::sqrt(b * b + 1) - b); };

My proposition to fix it is to make a protection if the delta of the endPoint and startPoint is smaller than 0.5 we set the delta is 0.5. That fix our issue.

@mention-bot

Copy link
Copy Markdown

@TranThuong, thanks for your PR! By analyzing this pull request, we identified @1ec5, @jfirebaugh and @incanus to be potential reviewers.

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. This line is intended to have the same effect. Perhaps the threshold does need to be loosened, though.

@tobrun

tobrun commented Feb 18, 2017

Copy link
Copy Markdown
Member

this would close #7295 on Android

@1ec5

1ec5 commented Feb 18, 2017

Copy link
Copy Markdown
Contributor

this would close #7295 on Android

I don’t think that’s the case. It merely loosens the threshold for turning a flyTo() into an easeTo(); an animation takes place regardless.

@1ec5 1ec5 added the Core The cross-platform C++ core, aka mbgl label Mar 4, 2017
@1ec5

1ec5 commented Mar 4, 2017

Copy link
Copy Markdown
Contributor

@mourner, do you recall where this threshold came from? I can’t find anything similar in the original paper describing flight animation.

@mourner

mourner commented Mar 6, 2017

Copy link
Copy Markdown
Member

@1ec5 it came originally from @ansis's implementation here cutting-room-floor/easey-DEAD#20.

@tobrun

tobrun commented Mar 7, 2017

Copy link
Copy Markdown
Member

@TranThuong been looking into the same issue myself in light of #8300. It seems that the value of u1=0.5 is not sufficient. In #8302 I'm trying to catch the root cause that could avoid this behaviour for all use-cases. Thank you for reaching out and contributing. Closing this in favor of #8302.

@tobrun tobrun closed this Mar 7, 2017
@mappy-mobile
mappy-mobile deleted the fix_animation_flyto_two_close_points branch March 15, 2017 13:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants