42 dial->threshold_squared = threshold * threshold;
49 float current_direction[2];
51 sub_v2_v2v2(current_direction, current_position, dial->center);
61 if (!dial->initialized) {
62 copy_v2_v2(dial->initial_direction, current_direction);
63 dial->initialized =
true;
67 cosval =
dot_v2v2(current_direction, dial->initial_direction);
68 sinval =
cross_v2v2(current_direction, dial->initial_direction);
71 angle =
atan2f(sinval, cosval);
76 if ((angle * dial->last_angle < 0.0f) && (
fabsf(dial->last_angle) > (
float)
M_PI_2)) {
77 if (dial->last_angle < 0.0f) {
84 dial->last_angle =
angle;
86 return angle + 2.0f * (
float)
M_PI * dial->rotations;
89 return dial->last_angle;
Dial * BLI_dial_init(const float start_position[2], float threshold)
float BLI_dial_angle(Dial *dial, const float current_position[2])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v2(float n[2])
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Read Guarded memory(de)allocation.
draw_view in_light_buf[] float
void *(* MEM_callocN)(size_t len, const char *str)
float initial_direction[2]