## Confused with the descriptions of transformPoint and inverseTransformPoint

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
shingoscar
Prole
Posts: 3
Joined: Fri Aug 28, 2020 2:01 pm

### Confused with the descriptions of transformPoint and inverseTransformPoint

I'm looking for definitions of global / local coordinates and screen-space in the love wiki.

These are the descriptions from the wiki.
love.graphics.transformPoint
Converts the given 2D position from global coordinates into screen-space.
global->screen

love.graphics.inverseTransformPoint
Converts the given 2D position from screen-space into global coordinates.
screen->global

Transform:transformPoint
This effectively converts the given position from global coordinates into the local coordinate space of the Transform.
global->local

Transform:inverseTransformPoint
This effectively converts the given position from the local coordinate space of the Transform into global coordinates.
local->global
The problem is as I learnt the global coordinate also known as world coordinate is an initial untransformed coordinate, the local coordinate is a transformed coordinate. In a 2D world the global coordinate is usually the window coordinate, so the most top left position is 0, 0 in this coordinate.
Orientation-based_coordinates

coord.png (6.75 KiB) Viewed 1131 times

So the transformPoint method is converting a point from local to world. Correct me if I'm wrong.

Code: Select all

local t = love.math.newTransform(100, 100, 10)
local globalX, globalY = 0, 0
local localX, localY = t:transformPoint(globalX, globalY)
-- Result: 100, 100

pgimeno
Party member
Posts: 2338
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Confused with the descriptions of transformPoint and inverseTransformPoint

shingoscar wrote:
Mon Oct 26, 2020 2:51 pm
So the transformPoint method is converting a point from local to world. Correct me if I'm wrong.
World coordinates, also called global coordinates, are the coordinates used by your program's world. Think map coordinates in the case of a game that uses a map. Or 3D position coordinates in case of a 3D program.

Screen coordinates are the coordinates used by the screen. They are always 2D, and the upper left corner is always (0, 0) while the lower right corner is always (screenWidth, screenHeight). (ETA: This is not entirely accurate; actually the Z is always 0).

One usually creates a transformation that maps world to screen coordinates. For example:

- Imagine you have a map which is exactly the same width and height of the screen.