Questions about x/y coordinates of MapPosition, ChunkPosition, TilePosition
Posted: Mon Jan 17, 2022 9:28 pm
I'm exporting tile-data based on events into a file, and I'm trying to combine them into chunks so that I can make PNGs of them.
I'm getting confused because I'm not clear on the coordinate system that Factorio is using, and whether it's the same for each of these different positions. I have a lot of questions, some are really basic, but I'd really like the answers all in one place.
(I did find a post explaining viewtopic.php?p=447586#p44758 how to convert from a ChunkPosition to a BoundingBox, which is part of the solution)
I'm getting confused because I'm not clear on the coordinate system that Factorio is using, and whether it's the same for each of these different positions. I have a lot of questions, some are really basic, but I'd really like the answers all in one place.
- Are the x/y of Position, MapPosition, ChunkPosition, and TilePosition all zero-indexed? Are they all (x:0, y:0) at the center of the map?
- Do all positions use Cartesian or screen coordinates? Does positive-y go up, or down? Does positive-x increase to the left, or to the right?
- Is the origin of TilePosition the center of the map, or a corner of a chunk If so, which corner? Should it go from 0 to 31?
- Is a ChunkPosition the largest x and y TilePosition in the chunk? Or the middle TilePosition?
- The ChunkPosition documentation says "A Position can be translated to a ChunkPosition by dividing the x/y values by 32.". Assuming ChunkPosition is zero-indexed, and the values are rounded down, what happens near the origin? Because that the Positions (x:31,y:31) and (x:-31,y:-31) will have ChunkPosition (x:0,y:0) - does this mean chunk (x:0, y:0) is 64 tiles in length/height?
- How can I get the ChunkPosition of any TilePosition? As in, given a list of any number of TilePositions (but no other information), how can I aggregate them so they are grouped per chunk?
(I did find a post explaining viewtopic.php?p=447586#p44758 how to convert from a ChunkPosition to a BoundingBox, which is part of the solution)