an unnamed video game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
303 B

  1. local util = {}
  2. function util.cartToIso(cart)
  3. local iso = {}
  4. iso.x = cart.x - cart.y
  5. iso.y = (cart.x + cart.y) / 2
  6. return iso
  7. end
  8. function util.isoToCart(iso)
  9. local cart = {}
  10. cart.x = (2 * iso.y + iso.x) / 2
  11. cart.y = (2 * iso.y - iso.x) / 2
  12. return cart
  13. end
  14. return util