语言

Menu
Sites
Language
What's the exact relationship between radius and zoom in Zoom_info?

 

I got the zoom info struct from code as above, but I'm puzzled on the relation ship between "zoom" and "radius". 

/**
 * @struct _Elm_Gesture_Zoom_Info
 * @brief The structure type that holds zoom info for the user.
 */
struct _Elm_Gesture_Zoom_Info
{
   Evas_Coord x, y; /**< Holds zoom center point reported to the user  */
   Evas_Coord radius; /**< Holds radius between fingers reported to the user */
   double     zoom; /**< Zoom value: @c 1.0 means no zoom             */
   double     momentum; /**< Zoom momentum: zoom growth per second (NOT YET SUPPORTED) */
};

/**
 * @typedef Elm_Gesture_Zoom_Info
 * @brief The structure type that holds zoom info for the user.
 */
typedef struct _Elm_Gesture_Zoom_Info Elm_Gesture_Zoom_Info;

Below are my codes to output zhe zoom info data when zoom event comes.

static Evas_Event_Flags zoom_start_cb(void *data , void *event_info)
{
    Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *)event_info;
 dlog_print(DLOG_ERROR, "zoom_start_cb", "Zoom info (x,y,radius,zoom,momentum) = (%d, %d, %d, %lf, %lf)", p->x, p->y, p->radius, p->zoom, p->momentum);

 return EVAS_EVENT_FLAG_ON_HOLD;
}

static Evas_Event_Flags zoom_move_cb(void *data , void *event_info)
{
 Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *)event_info;
 dlog_print(DLOG_ERROR, "zoom_move_cb", "Zoom info (x,y,radius,zoom,momentum) = (%d, %d, %d, %lf, %lf)", p->x, p->y, p->radius, p->zoom, p->momentum);

 return EVAS_EVENT_FLAG_ON_HOLD;
}

static Evas_Event_Flags zoom_end_cb(void *data , void *event_info)
{
 Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *)event_info;
 dlog_print(DLOG_ERROR, "zoom_end_cb", "Zoom info (x,y,radius,zoom,momentum) = (%d, %d, %d, %lf, %lf)", p->x, p->y, p->radius, p->zoom, p->momentum);

 return EVAS_EVENT_FLAG_ON_HOLD;
}

static Evas_Event_Flags zoom_abort_cb(void *data , void *event_info)
{
 Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *)event_info;
 dlog_print(DLOG_ERROR, "zoom_abort_cb", "Zoom info (x,y,radius,zoom,momentum) = (%d, %d, %d, %lf, %lf)", p->x, p->y, p->radius, p->zoom, p->momentum);

 return EVAS_EVENT_FLAG_ON_HOLD;
}

I got the log as below.

I find the zoom value does not proportional growth with raidus. What's the exact relationship between them? What are the exact geometric meaning for radius and zoom when two finger do zoom action on the screen? How the zoom value is caculated? How the raidus value is caculated?

 

编辑者为: Jean Yang 01 9月, 2015

响应

3 回复
Alex Dem

Hi,
I think radius should be distance from x,y (zoom center point) to x1,y1 (first finger touch coordinates) or to x2,y2 (second finger touch coordinates)
or this is 1/2 of diagonal from rectangle (x1,y1,x2,y2) .

I do not think that there could be other way to calculate.
Alexey.

Jean Yang

For the relation ship between radius and zoom ratio, it should be:

zoom ratio = radius_n / radius_0

Among the expression, radius_n is  the radius for the current two fingers dicided circle, radius_0 is the radius of the cirle where start to recognize the  zoom_move event.

For the data I listed in the topic, you can find the first zoom info for zoom_move_cb is:

It will be the base to caculate the zoom ratio, so it's zoom ration is 1.00000. So the radius_0 = 121.

While, the following zoom info for zoom_move_cb is:

The radius_1 = 126, so zoom ratio = radius_1 / radius_0 = 126 / 121 = 1.04132. This value is not exact equal to 1.045455. It should be invovled by the int type of radius in the zoom_info structure, it's a rounding value.

Let's check this with the second followed zoom info for zoom_move_cb:

The radius_2 = 127, so zoom ratio = radius_2 / radius_0 = 127 / 121 = 1.049586776. It is just the output zoom ratio.

Each zoom_move_start event will clear the zoom ratio to 1.00000.

 

 

Jean Yang

I try to get the geometry meaning for the zoom operation. Below are the zoom info data for one group of events for a zoom out operation.

Draw the centers and circles with the screen framework on the canvas, I got:

To make it clear, I enlarge it as below picture.

We can see the center motion trajectory directly from the picture. If each circle is decided by the position of two fingers, the two fingers is only possible at the two end of a diameter for the circle. So we can imaging the finger motion trajectory as below picture.

From above geometrical presentation of zoom info, we should can clearly understanding the structure _Elm_Gesture_Zoom_Info now.