Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local continentRect = {
- [0] = {
- [0] = 19456,
- [1] = 14976,
- },
- [1] = {
- [0] = 21760,
- [1] = 18176,
- },
- }
- local mapRect = {
- [0] = {
- [0] = -27648,
- [1] = -36864,
- },
- [1] = {
- [0] = 27648,
- [1] = 39936,
- },
- }
- local coords = {
- [0] = 20806.8,
- [1] = 16337.3,
- }
- --[[ function from the gw2 wiki (but is seems to not work as expected.]]
- function recalc_coords(continent_rect, map_rect, coords)
- return {
- 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])),
- 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])))
- }
- end
- d(recalc_coords(continentRect,mapRect,coords))
- d("desired result:")
- d({4771.2,7264.8})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement