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

Pitch rounding errors #585

Open
jfitie opened this Issue May 8, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jfitie
Member

jfitie commented May 8, 2018

The pitch variable in the navit struct should be changed from an int to a float data type so that pitch correction (see #303 and #306) does not have to round the result. Currently, this is causing some problems with the pitch in high resolution displays where the correction causes the stored pitch value to be a low value.

F.ex. on a Galaxy S9+ with a display resolution of 2960x1440px the default pitch of 20 gets stored as 20*sqrt(240*320)/sqrt(2960*1440)=2.68… which gets rounded to 3. In reverse, this effectively means a pitch of 3*sqrt(2960*1440)/sqrt(240*320)=22.34… which gets rounded to 22.
This is a 10% error.

Definition: https://github.com/navit-gps/navit/blob/trunk/navit/navit.c#L166
Round function should be removed at: https://github.com/navit-gps/navit/blob/trunk/navit/navit.c#L2620 and https://github.com/navit-gps/navit/blob/trunk/navit/navit.c#L2860

Not sure at what other locations changes should be made.

@pgrandin

This comment has been minimized.

Contributor

pgrandin commented May 25, 2018

Sounds good.

Want to submit a PR for this?

It looks like we have a couple more places where this would need to be changed :

./navit/gui/gtk/gui_gtk_window.c:		transform_set_pitch(t, (transform_get_pitch(t)+5)%360);
./navit/gui/gtk/gui_gtk_window.c:		transform_set_pitch(t, (transform_get_pitch(t)-5)%360);
./navit/transform.h:void transform_set_pitch(struct transformation *this_, int pitch);
./navit/navit.c:		transform_set_pitch(this_->trans, round(this_->pitch*sqrt(240*320)/sqrt(
./navit/transform.c:transform_set_pitch(struct transformation *this_,int pitch)
./navit/plugin/pedestrian/pedestrian.c:				transform_set_pitch(trans, 90+(val-0x80));
./navit/plugin/pedestrian/pedestrian.c:			transform_set_pitch(trans, (int)pitch);
./navit/plugin/pedestrian/pedestrian.c:		transform_set_pitch(trans, 90);
./navit/plugin/pedestrian/pedestrian.c:	transform_set_pitch(trans, 90);

and the relevant function prototype would need to be changed as well:

transform_set_pitch(struct transformation *this_,int pitch)
and

It doesn't look like the calls to transform_get_pitch() need to be changed as we never store the value, but pass it back to transform_get_pitch() instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment