Advertisement
Guest User

Untitled

a guest
May 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local continentRect = {
  2.     [0] = {
  3.         [0] = 19456,
  4.         [1] = 14976,
  5.     },
  6.     [1] = {
  7.         [0] = 21760,
  8.         [1] = 18176,
  9.     },
  10. }
  11. local mapRect = {
  12.     [0] = {
  13.         [0] = -27648,
  14.         [1] = -36864,
  15.     },
  16.     [1] = {
  17.         [0] = 27648,
  18.         [1] = 39936,
  19.     },
  20. }
  21. local coords = {
  22.     [0] = 20806.8,
  23.     [1] = 16337.3,
  24. }
  25.  
  26. --[[ function from the gw2 wiki (but is seems to not work as expected.]]
  27. function recalc_coords(continent_rect, map_rect, coords)
  28.     return {
  29.         math.round(continent_rect[0][0]+(continent_rect[1][0]-continent_rect[0][0])*(coords[0]-map_rect[0][0])/(map_rect[1][0]-map_rect[0][0])),
  30.         math.round(continent_rect[0][1]+(continent_rect[1][1]-continent_rect[0][1])*(1-(coords[1]-map_rect[0][1])/(map_rect[1][1]-map_rect[0][1])))
  31.     }
  32. end
  33.  
  34. d(recalc_coords(continentRect,mapRect,coords))
  35. d("desired result:")
  36. d({4771.2,7264.8})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement