• Create Account

### #ActualAshaman73

Posted 25 September 2012 - 11:33 PM

The mathematical way is to use a transformation, at least a projection on the new axis.
For this you need the two edges of a iso tile and the origin in screenspace (could be negative).

Edge for the x axis would be [(0,0) ,(32,-32)], edge for the y axis would be [(0,0),(32,32)], this are two axis vectors x_axis=(32,-32) and y_axis=(32,32).
Now you need to project your mouse position on the normalized axis, this can be done by using the dot product and you need to finally scale it down by the edge length to get the correct tile:

x_tile = dot(norm(x_axis), mouse_position) * (1/length(32,-32))
y_tile = dot(norm(y_axis), mouse_position) * (1/length(32,32))
<=>
x_tile = dot( norm(32,-32), (mx,my)) * (1/length(32,-32))
y_tile = dot( norm(32,32), (mx,my)) * (1/length(32,32))
<=>
x_tile = dot( (32,-32), (mx,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = dot( (32,32), (mx,my)) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = (32*mx+32*my) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/dot(32,-32))
y_tile = (32*mx+32*my) * (1/dot(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/(32*32+(-32)*(-32)))
y_tile = (32*mx+32*my) * (1/(32*32+32*32))
<=>
x_tile = (32*mx+(-32*my)) * (1/2048)
y_tile = (32*mx+32*my) * (1/2048)


To get the correct coords, you need to offest the mouse by the screen offset, the final formular would look like:

new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (32*new_mx+(-32*new_my)) /2048
y_tile = (32*new_mx+32*new_my) /2048


Optimized:
new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (new_mx-new_my)) /64
y_tile = (new_mx+new_my) /64


### #5Ashaman73

Posted 25 September 2012 - 11:31 PM

The mathematical way is to use a transformation, at least a projection on the new axis.
For this you need the two edges of a iso tile and the origin in screenspace (could be negative).

Edge for the x axis would be [(0,0) ,(32,-32)], edge for the y axis would be [(0,0),(32,32)], this are two axis vectors x_axis=(32,-32) and y_axis=(32,32).
Now you need to project your mouse position on the normalized axis, this can be done by using the dot product and you need to finally scale it down by the edge length to get the correct tile:

x_tile = dot(norm(x_axis), mouse_position) * (1/length(32,-32))
y_tile = dot(norm(y_axis), mouse_position) * (1/length(32,32))
<=>
x_tile = dot( norm(32,-32), (mx,my)) * (1/length(32,-32))
y_tile = dot( norm(32,32), (mx,my)) * (1/length(32,32))
<=>
x_tile = dot( (32,-32), (mx,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = dot( (32,32), (mx,my)) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = (32*mx+32*my) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/dot(32,-32))
y_tile = (32*mx+32*my) * (1/dot(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/(32*32+(-32)*(-32)))
y_tile = (32*mx+32*my) * (1/(32*32+32*32))
<=>
x_tile = (32*mx+(-32*my)) * (1/2048)
y_tile = (32*mx+32*my) * (1/2048)


To get the correct coords, you need to offest the mouse by the screen offset, the final formular would look like:

new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (32*new_mx+(-32*new_my)) /2048
y_tile = (32*new_mx+32*new_my) /2048


### #4Ashaman73

Posted 25 September 2012 - 11:31 PM

The mathematical way is to use a transformation, at least a projection on the new axis.
For this you need the two edges of a iso tile and the origin in screenspace (could be negative).

Edge for the x axis would be [(0,0) ,(32,-32)], edge for the y axis would be [(0,0),(32,32)], this are two axis vectors x_axis=(32,-32) and y_axis=(32,32).
Now you need to project your mouse position on the normalized axis, this can be done by using the dot product and you need to finally scale it down by the edge length to get the correct tile:

x_tile = dot(norm(x_axis), mouse_position) * (1/length(32,-32))
y_tile = dot(norm(y_axis), mouse_position) * (1/length(32,32))
<=>
x_tile = dot( norm(32,-32), (mx,my)) * (1/length(32,-32))
y_tile = dot( norm(32,32), (mx,my)) * (1/length(32,32))
<=>
x_tile = dot( (32,-32), (mx,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = dot( (32,32), (mx,my)) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = (32*mx+32*my) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/dot(32,-32))
y_tile = (32*mx+32*my) * (1/dot(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/(32*32+(-32)*(-32)))
y_tile = (32*mx+32*my) * (1/(32*32+32*32))
<=>
x_tile = (32*mx+(-32*my)) * (1/2048)
y_tile = (32*mx+32*my) * (1/2048)


To get the correct coords, you need to offest the mouse by the screen offset, the final formular would look like:

new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (32*new_mx+(-32*new_my)) /2048
y_tile = (32*new_mx+32*new_my) /2048


### #3Ashaman73

Posted 25 September 2012 - 11:30 PM

The mathematical way is to use a transformation, at least a projection on the new axis.
For this you need the two edges of a iso tile and the origin in screenspace (could be negative).

Edge for the x axis would be [(0,0) ,(32,-32)], edge for the y axis would be [(0,0),(32,32)], this are two axis vectors x_axis=(32,-32) and y_axis=(32,32).
Now you need to project your mouse position on the normalized axis, this can be done by using the dot product and you need to finally scale it down by the edge length to get the correct tile:

x_tile = dot(norm(x_axis), mouse_position) * (1/length(32,-32))
y_tile = dot(norm(y_axis), mouse_position) * (1/length(32,32))
<=>
x_tile = dot( norm(32,-32), (mx,my)) * (1/length(32,-32))
y_tile = dot( norm(32,32), (mx,my)) * (1/length(32,32))
<=>
x_tile = dot( (32,-32), (mx,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = dot( (32,32), (mx,my)) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = (32*mx+32*my) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/dot(32,-32))
y_tile = (32*mx+32*my) * (1/dot(32,32))
<=>
x_tile = (32*mx+(-32*my)) * (1/(32*32+(-32)*(-32)))
y_tile = (32*mx+32*my) * (1/(32*32+32*32))
<=>
x_tile = (32*mx+(-32*my)) * (1/2048)
y_tile = (32*mx+32*my) * (1/2048)


To get the correct coords, you need to offest the mouse by the screen offset, the final formular would look like:

new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (32*new_mx+(-32*new_my)) * (1/2048)
y_tile = (32*new_mx+32*new_my) * (1/2048)


### #2Ashaman73

Posted 25 September 2012 - 11:29 PM

The mathematical way is to use a transformation, at least a projection on the new axis.
For this you need the two edges of a iso tile and the origin in screenspace (could be negative).

Edge for the x axis would be [(0,0) ,(32,-32)], edge for the y axis would be [(0,0),(32,32)], this are two axis vectors x_axis=(32,-32) and y_axis=(32,32).
Now you need to project your mouse position on the normalized axis, this can be done by using the dot product and you need to finally scale it down by the edge length to get the correct tile:

x_tile = dot(norm(x_axis), mouse_position) * (1/length(32,-32))
y_tile = dot(norm(y_axis), mouse_position) * (1/length(32,32))
<=>
x_tile = dot( norm(32,-32), (mx,my)) * (1/length(32,-32))
y_tile = dot( norm(32,32), (mx,my)) * (1/length(32,32))
<=>
x_tile = dot( (32,-32), (mx,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = dot( (32,32), (mx,my)) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = (32*mx+32*my) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32,my)) * (1/dot(32,-32))
y_tile = (32*mx+32*my) * (1/dot(32,32))
<=>
x_tile = (32*mx+(-32,my)) * (1/(32*32+(-32)*(-32)))
y_tile = (32*mx+32*my) * (1/(32*32+32*32))
<=>
x_tile = (32*mx+(-32,my)) * (1/2048)
y_tile = (32*mx+32*my) * (1/2048)


To get the correct coords, you need to offest the mouse by the screen offset, the final formular would look like:

new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (32*new_mx+(-32,new_my)) * (1/2048)
y_tile = (32*new_mx+32*new_my) * (1/2048)


### #1Ashaman73

Posted 25 September 2012 - 11:29 PM

The mathematical way is to use a transformation, at least a projection on the new axis.
For this you need the two edges of a iso tile and the origin in screenspace (could be negative).

Edge for the x axis would be [(0,0) ,(32,-32)], edge for the y axis would be [(0,0),(32,32)], this are two axis vectors x_axis=(32,-32) and y_axis=(32,32).
Now you need to project your mouse position on the normalized axis, this can be done by using the dot product and you need to final scale it down by the edge length to get the correct tile:

x_tile = dot(norm(x_axis), mouse_position) * (1/length(32,-32))
y_tile = dot(norm(y_axis), mouse_position) * (1/length(32,32))
<=>
x_tile = dot( norm(32,-32), (mx,my)) * (1/length(32,-32))
y_tile = dot( norm(32,32), (mx,my)) * (1/length(32,32))
<=>
x_tile = dot( (32,-32), (mx,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = dot( (32,32), (mx,my)) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32,my)) * (1/length(32,-32)) * (1/length(32,-32))
y_tile = (32*mx+32*my) * (1/length(32,32)) * (1/length(32,32))
<=>
x_tile = (32*mx+(-32,my)) * (1/dot(32,-32))
y_tile = (32*mx+32*my) * (1/dot(32,32))
<=>
x_tile = (32*mx+(-32,my)) * (1/(32*32+(-32)*(-32)))
y_tile = (32*mx+32*my) * (1/(32*32+32*32))
<=>
x_tile = (32*mx+(-32,my)) * (1/2048)
y_tile = (32*mx+32*my) * (1/2048)


To get the correct coords, you need to offest the mouse by the screen offset, the final formular would look like:

new_mx = mx + screen_offset_x
new_my = my + screen_offsety_y
x_tile = (32*new_mx+(-32,new_my)) * (1/2048)
y_tile = (32*new_mx+32*new_my) * (1/2048)


PARTNERS