Determines if two drag actions are the same.
(
drag_1_touch_yx,
drag_1_lift_yx,
drag_2_touch_yx,
drag_2_lift_yx,
)
| 212 | |
| 213 | |
| 214 | def _check_drag_actions_match( |
| 215 | drag_1_touch_yx, |
| 216 | drag_1_lift_yx, |
| 217 | drag_2_touch_yx, |
| 218 | drag_2_lift_yx, |
| 219 | ): |
| 220 | """Determines if two drag actions are the same.""" |
| 221 | # Store drag deltas (the change in the y and x coordinates from touch to |
| 222 | # lift), magnitudes, and the index of the main axis, which is the axis with |
| 223 | # the greatest change in coordinate value (e.g. a drag starting at (0, 0) and |
| 224 | # ending at (0.3, 0.5) has a main axis index of 1). |
| 225 | drag_1_deltas = drag_1_lift_yx - drag_1_touch_yx |
| 226 | drag_1_magnitudes = jnp.abs(drag_1_deltas) |
| 227 | drag_1_main_axis = np.argmax(drag_1_magnitudes) |
| 228 | drag_2_deltas = drag_2_lift_yx - drag_2_touch_yx |
| 229 | drag_2_magnitudes = jnp.abs(drag_2_deltas) |
| 230 | drag_2_main_axis = np.argmax(drag_2_magnitudes) |
| 231 | |
| 232 | return jnp.equal(drag_1_main_axis, drag_2_main_axis) |
| 233 | |
| 234 | |
| 235 | def check_actions_match( |
no outgoing calls
no test coverage detected