Archived

This topic is now archived and is closed to further replies.

graveyard filla

difference between absolute and relative positions of the mouse?

Recommended Posts

can someone explain the difference between the 2? im using SDL if that matters. i searched the forums and found a bunch of threads with questions on the relative/absoluteness, but none describing the difference bettwen the 2. thanks for any help [edited by - graveyard filla on March 22, 2004 2:18:26 AM]

Share this post


Link to post
Share on other sites
Nik02    4348
Relative coordinates describe how much the mouse has moved during last poll interval, while absolute coords describe how much the mouse has moved during entire application (implementation details vary).

-Nik

Share this post


Link to post
Share on other sites
jack_1313    536
It is my understanding that absolute refers to the position of the cursor on screen (which is what Nik02''s observation would amount to). Eg the centre of the screen would be SCREEN_WIDTH/2,SCREEN_HEIGHT/2.
Relative refers to the amount of units the mouse has moved since it was last checked. Ie if you checked the aboslute mouse co-ordinates and they were 100,100, waited a moment and checked again to get 150,90, your relative mouse co-ordinates would be 50,-10.
Given an initial and an updated pair of absoulte co-ordinates, you can find the relative co-ordinates with:

relative_pos = updated_pos - initial_pos.

(relative_posx = updated_posx - initial_posx
relative_posy = updated_posy - initial_posy)

Depending on what input engine you use, you may find that you can specify whether to get relative or absoulte mouse co-ordinates.

Share this post


Link to post
Share on other sites
Nik02    4348
quote:
Original post by jack_1313
It is my understanding that absolute refers to the position of the cursor on screen (which is what Nik02''s observation would amount to). Eg the centre of the screen would be SCREEN_WIDTH/2,SCREEN_HEIGHT/2.
Relative refers to the amount of units the mouse has moved since it was last checked. Ie if you checked the aboslute mouse co-ordinates and they were 100,100, waited a moment and checked again to get 150,90, your relative mouse co-ordinates would be 50,-10.
Given an initial and an updated pair of absoulte co-ordinates, you can find the relative co-ordinates with:

relative_pos = updated_pos - initial_pos.

(relative_posx = updated_posx - initial_posx
relative_posy = updated_posy - initial_posy)

Depending on what input engine you use, you may find that you can specify whether to get relative or absoulte mouse co-ordinates.


Mouse system (as in DI or SDL) isn''t aware of the "screen" itself, it is the application''s responsibility to convert the input to something useful (for example, cursor screen-space position, or something entirely different). That''s why i stated that implementation details vary.

The point is: More often than not, absolute mouse coordinates are indeed used to place the cursor on the screen, but it is not by any means mandatory to use them like that.

-Nik

Share this post


Link to post
Share on other sites