Public Group

#### Archived

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

# difference between absolute and relative positions of the mouse?

This topic is 5206 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 on other sites
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 on other sites
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

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 11
• 21
• 12
• 12
• 11
×