-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcoordinates.txt
42 lines (25 loc) · 1.49 KB
/
coordinates.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Chunkmapper projects the earth onto an arcsecond resolution rectangular grid. Given a point P(lat, lon, alt) the chunkmapper coordinates are
absx = lon * 3600
absz = -lat * 3600
absy = alt / 31
where lat is degrees north of the equator, lon is degrees east of Greenwich and alt is altitude in metres. Lat varies from -90 to 90 and lon varies from from -180 to 180. Longitudinal wrapping is not currently implemented, so if you cross the International Date Line or the north or south poles there's just open ocean. The rectangular projection stretches earth along an east-west axis by factor 1/cos(lat).
Given a Chunkmapper block at coordinates (x, y, z) there are two additional coordinate systems
chunkx = x / 16 mod 32
chunkz = z / 16 mod 32
and
regionx = x / 512
regionz = z / 512
Each (regionx, regionz) coordinate is independently generated, speeding execution on multi-CPU machines. To facilitate top-down mapping a root point (rootPointx, rootPointz) is defined as
rootPointx = x0 / 512
rootPointz = z0 / 512
where (x0, z0) are the intial coordinates selected by the player in the gui. This enables Minecraft coordinates to be calculated as
x = absx - rootPointx * 512
y = absy
z = absz - rootPoinz - 512
Notes
For some strange reason the creators of Java used an unorthodox definition of mod that allows negative numbers and breaks circular symmetry.
e.g.
(-1) mod 5 = -1.
instead of
(-1) mod 5 = 4
I don't know why they did that but it means you must be careful to define your own mod operator!!!