mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-31 11:10:08 +01:00
Add a helper for radians to degrees
This commit is contained in:
parent
3fd38d8927
commit
cf1c07e066
3 changed files with 9 additions and 3 deletions
|
|
@ -324,7 +324,7 @@ tp_gesture_get_pinch_info(struct tp_dispatch *tp,
|
|||
delta = device_delta(first->point, second->point);
|
||||
normalized = tp_normalize_delta(tp, delta);
|
||||
*distance = normalized_length(normalized);
|
||||
*angle = atan2(normalized.y, normalized.x) * 180.0 / M_PI;
|
||||
*angle = rad2deg(atan2(normalized.y, normalized.x));
|
||||
|
||||
*center = device_average(first->point, second->point);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ adjust_tilt(const struct input_absinfo *absinfo)
|
|||
if (absinfo->resolution != 0 &&
|
||||
absinfo->maximum > 0 &&
|
||||
absinfo->minimum < 0) {
|
||||
value = 180.0/M_PI * absinfo->value/absinfo->resolution;
|
||||
value = rad2deg((double)absinfo->value/absinfo->resolution);
|
||||
} else {
|
||||
/* Wacom supports physical [-64, 64] degrees, so map to that by
|
||||
* default. If other tablets have a different physical range or
|
||||
|
|
@ -419,7 +419,7 @@ convert_tilt_to_rotation(struct tablet_dispatch *tablet)
|
|||
|
||||
/* atan2 is CCW, we want CW -> negate x */
|
||||
if (x || y)
|
||||
angle = ((180.0 * atan2(-x, y)) / M_PI);
|
||||
angle = rad2deg(atan2(-x, y));
|
||||
|
||||
angle = fmod(360 + angle - offset, 360);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ deg2rad(int degree)
|
|||
return M_PI * degree / 180.0;
|
||||
}
|
||||
|
||||
static inline double
|
||||
rad2deg(double rad)
|
||||
{
|
||||
return 180.0 / M_PI * rad;
|
||||
}
|
||||
|
||||
static inline void
|
||||
matrix_init_identity(struct matrix *m)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue