/** * clutter_event_get_angle: * @source: a #ClutterEvent * @target: a #ClutterEvent * * Retrieves the angle relative from @source to @target. * * The direction of the angle is from the position X axis towards * the positive Y axis. * * Return value: the angle between two #ClutterEvent * * Since: 1.12 */ double clutter_event_get_angle (const ClutterEvent *source, const ClutterEvent *target) { ClutterPoint p0, p1; float x_distance, y_distance; double angle; clutter_event_get_position (source, &p0); clutter_event_get_position (target, &p1); if (clutter_point_equals (&p0, &p1)) return 0; clutter_point_distance (&p0, &p1, &x_distance, &y_distance); angle = atan2 (x_distance, y_distance); /* invert the angle, and shift it by 90 degrees */ angle = (2.0 * G_PI) - angle; angle += G_PI / 2.0; /* keep the angle within the [ 0, 360 ] interval */ angle = fmod (angle, 2.0 * G_PI); return angle; }
/** * clutter_point_distance: * @a: a #ClutterPoint * @b: a #ClutterPoint * @x_distance: (out) (allow-none): return location for the horizontal * distance between the points * @y_distance: (out) (allow-none): return location for the vertical * distance between the points * * Computes the distance between two #ClutterPoint. * * Return value: the distance between the points. * * Since: 1.12 */ float clutter_point_distance (const ClutterPoint *a, const ClutterPoint *b, float *x_distance, float *y_distance) { float x_d, y_d; g_return_val_if_fail (a != NULL, 0.f); g_return_val_if_fail (b != NULL, 0.f); if (clutter_point_equals (a, b)) return 0.f; x_d = (a->x - b->x); y_d = (a->y - b->y); if (x_distance != NULL) *x_distance = fabsf (x_d); if (y_distance != NULL) *y_distance = fabsf (y_d); return sqrt ((x_d * x_d) + (y_d * y_d)); }
/** * clutter_rect_equals: * @a: a #ClutterRect * @b: a #ClutterRect * * Checks whether @a and @b are equals. * * This function will normalize both @a and @b before comparing * their origin and size. * * Return value: %TRUE if the rectangles match in origin and size. * * Since: 1.12 */ gboolean clutter_rect_equals (ClutterRect *a, ClutterRect *b) { if (a == b) return TRUE; if (a == NULL || b == NULL) return FALSE; clutter_rect_normalize_internal (a); clutter_rect_normalize_internal (b); return clutter_point_equals (&a->origin, &b->origin) && clutter_size_equals (&a->size, &b->size); }