Jump to content

Coordinate system

From Galactic Empire wiki

Galactic Empire locates ships, planets, mines, and wormholes on a continuous two-dimensional map. The game reports that location in two parts: a sector and a position within the sector. It also uses compass headings and bearings to describe direction. Keeping those three ideas separate makes navigation reports and scans much easier to interpret.

Direction of the axes

GE's map follows the convention of a screen display: X increases to the right (east), and Y increases downward (south). Decreasing X moves west; decreasing Y moves north. For example, sector 1 0 is east of 0 0, while sector 0 -1 is north of it.

In the usual Cartesian diagram used to teach trigonometry, positive Y points up, and angles are often measured counterclockwise from the positive X axis. GE does neither. Its headings are compass headings measured clockwise from north: 0 degrees points north (toward decreasing Y), 90 east (increasing X), 180 south (increasing Y), and 270 west (decreasing X). The movement calculation reflects this: the X change is proportional to sin(heading), while the Y change is proportional to -cos(heading). Thus heading 0 decreases Y and heading 90 increases X.

Heading Direction Change in position
0 North Y decreases
90 East X increases
180 South Y increases
270 West X decreases

World coordinates and sectors

Internally, each axis is stored as a floating-point coordinate measured in sectors. The integer part identifies a sector, and the fractional part identifies a position inside it. The game obtains a sector number with floor(world coordinate), not by rounding to the nearest sector or truncating toward zero. A sector covers one unit of world coordinate on each axis, or 10,000 displayed distance units by 10,000.

Sector 0 0 occupies world X and Y coordinates from 0.0 up to, but not including, 1.0. Its usual central position is 5000 5000, corresponding to world coordinates (0.5, 0.5). The point (0.0, 0.0) is the northwestern corner of sector 0 0, not its center. Sector 0 0 is nevertheless the central sector of the galaxy and, in the standard game, the neutral zone.

Negative coordinates illustrate why floor() matters. A world X coordinate of -0.25 is in sector -1, because floor(-0.25) = -1. It is three quarters of the way across that sector, so its local X position is 7500. A ship at world coordinates (-0.25, 0.5) therefore reports sector -1 0 and local position 7500 5000. Crossing the western edge of sector 0 0 (world X drops below 0.0) enters sector -1 0; crossing its northern edge (world Y drops below 0.0) enters sector 0 -1.

Positions within a sector run from approximately 0 to 9999 on each axis. When movement carries a ship across an edge, its world position continues smoothly; only the sector and local-position representation change. For instance, moving east from near local X 9999 in sector 0 0 puts the ship near local X 0 in sector 1 0. There is no separate teleport at an ordinary sector boundary.

Distance, heading, and bearing

GE calculates distance from the differences between the underlying floating-point X and Y coordinates, then multiplies the result by 10,000 for the distance shown to players. Two ships at the centers of adjacent sectors, such as (0 0, 5000 5000) and (1 0, 5000 5000), are 10,000 displayed units apart. A ship just across a sector boundary can be much closer than that. Scans and navigation calculations use the underlying positions rather than treating every object in a sector as if it were at the sector's center.

An absolute heading gives the direction a ship faces in the galactic coordinate system. A relative bearing instead describes where a target lies compared with the observing ship's current heading: 0 is straight ahead, positive values turn toward starboard/right, negative values toward port/left, and 180 is directly behind. For example, a target due east has an absolute bearing of 90 degrees; to a ship facing north its relative bearing is +90, but to a ship facing east it is 0. See Rotation and headings for how turns and absolute headings are used in commands.

A ship scan's Heading field is different again: it tells how the scanned ship is oriented relative to the line from that ship back toward the observer. A value near 0 means the scanned ship faces toward the observer; a value near 180 means it faces away. The detailed ship scan can also show that ship's absolute galactic heading.

Galaxy radius and the perimeter

UNIVMAX is intended to be the number of sectors extending outward from sector 0 0 on each axis. With the default value 300, the intended sector numbers are -300 through 300, inclusive: 300 + 1 + 300 = 601 sectors across, or a 601 by 601 galaxy. This describes the legal coordinate range, not 361,201 sector records created in advance. Sectors and their contents are generally generated when first requested, such as when a ship enters or scans one.

Classic GE 3.2e checks the raw world coordinate against UNIVMAX at the positive edge. At the default setting, crossing beyond X or Y 300.0 triggers the perimeter response or wraparound. Because sector 300 would occupy coordinates from 300.0 to just under 301.0, it has no usable width in classic. The complete sectors on each axis are -300 through 299: 600 by 600, despite the radius setting's description. The exact coordinate 300.0 is a boundary point, not a traversable full sector.

ge-next 0.1 changed the positive test to the far edge of sector UNIVMAX, at UNIVMAX + 1. With UNIVMAX=300, sector 300 now has its full 10,000-unit width, up to the boundary at world coordinate 301. The negative edge remains at -300, so the complete sector range is -300 through 300: 601 by 601. When UNIVWRAP is enabled, ge-next also uses the corresponding 601-sector wrap distance, carrying a ship that leaves sector 300 into sector -300, and vice versa. With wrapping off, crossing the edge invokes the damaging perimeter response instead. See Classic bug: Galactic perimeter edge errors for the detailed classic behavior and later ge-next refinements.

Precision and display

World positions and headings are floating-point values, while most reports show integer sector positions, distances, and bearings. A displayed local coordinate is therefore a simplified view of a more precise position; two ships can appear to have the same reported coordinates without occupying exactly the same point. The sector maps in scans also compress many distance units into each character cell. Exact axis alignment exposed an additional error in classic bearing calculations; see Classic bug: Axis-aligned bearing errors.

See also