return new_pos;
}
+double view::inertial_camera::calc_next_step_lon(const double &start,
+ const double &finish,
+ const double step_ratio) const
+{
+ if(start == finish)
+ return start;
+
+ double _f = finish;
+ double _s = start;
+ if (_f < 0) _f += 360;
+ if (_s < 0) _s += 360;
+
+ double gap, gap1, gap2;
+ if (_f > _s) {
+ gap1 = _f - _s;
+ gap2 = (360 - _f) + _s;
+ if (gap1 < gap2)
+ gap = gap1;
+ else
+ gap = gap2 * -1;
+ } else {
+ gap1 = _s - _f;
+ gap2 = (360 - _s) + _f;
+ if (gap1 < gap2)
+ gap = gap1 * -1;
+ else
+ gap = gap2;
+ }
+
+ double step = gap * step_ratio;
+ double new_pos = start + step;
+ if (new_pos > 180)
+ new_pos -= 360;
+ else if (new_pos < -180)
+ new_pos += 360;
+
+ return new_pos;
+}
+
bool view::inertial_camera::next_transition_step()
{
if(!_view)
double next_lat = calc_next_step(prev_lat, target_lat, .15);
if (next_lat != prev_lat) transiting = true;
- double next_lon = calc_next_step(prev_lon, target_lon, .15);
+ double next_lon = calc_next_step_lon(prev_lon, target_lon, .15);
if (next_lon != prev_lon) transiting = true;
if (transiting)
if(!transiting_part[i])
continue;
- unsigned int timestamp = _last[i]._timestamp
- + get_transition_time(i);
+ unsigned int timestamp = _last[i]._timestamp + get_transition_time(i);
const touch_point tp(_cur_x[i], _cur_y[i], timestamp);
- MAPS_LOGI("TRANSITION finger %d up FAKE BRAKE time: %d",
- i, tp._timestamp);
+ MAPS_LOGI("TRANSITION finger %d up FAKE BRAKE time: %d", i, tp._timestamp);
_d->up(i, tp);
}
const int delta_x = _last[finger_no]._x - _prev[finger_no]._x;
const int delta_y = _last[finger_no]._y - _prev[finger_no]._y;
- unsigned int dt =
- _last[finger_no]._timestamp - _prev[finger_no]._timestamp;
+ unsigned int dt = _last[finger_no]._timestamp - _prev[finger_no]._timestamp;
int trajectory = get_trajectory_effective_length(_down[finger_no], tp);
MAPS_LOGD("trajectory=%d", trajectory);
transiting_part[i] = false;
if(ABS(_derivative_x[i]) > __ACCURACY) {
- _cur_x[i] = get_next_point(_cur_x[i],
- _derivative_x[i],
- _dt[i]);
- _derivative_x[i] = get_next_derivative(_derivative_x[i],
- _dt[i]);
- transiting_part[i] |=
- ABS(_derivative_x[i]) > __ACCURACY;
+ _cur_x[i] = get_next_point(_cur_x[i], _derivative_x[i], _dt[i]);
+ _derivative_x[i] = get_next_derivative(_derivative_x[i], _dt[i]);
+ transiting_part[i] |= ABS(_derivative_x[i]) > __ACCURACY;
}
if(ABS(_derivative_y[i]) > __ACCURACY) {
- _cur_y[i] = get_next_point(_cur_y[i],
- _derivative_y[i],
- _dt[i]);
- _derivative_y[i] =
- get_next_derivative(_derivative_y[i],
- _dt[i]);
- transiting_part[i] |=
- ABS(_derivative_y[i]) > __ACCURACY;
+ _cur_y[i] = get_next_point(_cur_y[i], _derivative_y[i], _dt[i]);
+ _derivative_y[i] = get_next_derivative(_derivative_y[i], _dt[i]);
+ transiting_part[i] |= ABS(_derivative_y[i]) > __ACCURACY;
}
- unsigned int timestamp = _last[i]._timestamp
- + get_transition_time(i);
+ unsigned int timestamp = _last[i]._timestamp + get_transition_time(i);
const touch_point tp(_cur_x[i], _cur_y[i], timestamp);
if(transiting_part[i]) {
- MAPS_LOGI("TRANSITION finger %d move FAKE time: %d",
- i, tp._timestamp);
+ MAPS_LOGI("TRANSITION finger %d move FAKE time: %d", i, tp._timestamp);
_d->move(i, tp);
} else {
- MAPS_LOGI("TRANSITION finger %d up FAKE time: %d",
- i, tp._timestamp);
+ MAPS_LOGI("TRANSITION finger %d up FAKE time: %d", i, tp._timestamp);
_d->up(i, tp);
}