Skip to main content

coordinate

Provides several functions for working with Coordinates

Note that you will see references to a 'CoordinateBounds' type, this is just an array structed as:

{
Vector2.new(-100, 100), -- universe x ranges from -100 to 100 (inclusive)
Vector2.new(-100, 100), -- universe y ranges from -100 to 100 (inclusive)
Vector2.new(-10, 10), -- solar x ranges from -10 to 10 (inclusive)
Vector2.new(-10, 10), -- solar y ranges from -10 to 10 (inclusive)
}

That being, an array containing for Vector2s, each one representing the minimm and maximum value for that component of the coordinate.

new(ux, uy, sx, sy, inPlanet)​

ux and uy are integers and represent the universe X and Y coordinaes of the resulting coordinate.

sx and sy are integers and represent the solar X and Y coordinaes of the resulting coordinate.

inPlanet is a boolean as to whether the resulting coordinate should represent a planet or a planets orbit.

fromString(coordinate, bounds)​

Returns a Coordinate given the familiar format of a string "0, 0, 0, 0, false".

bounds is a CoordinateBounds, and will clamp the coordinate string.

fromVectors(universeCoordinate, solarCoordinate, inPlanet)​

Returns a Coordinate given the format Vector2.new(universeX, universeY), Vector2.new(solarX, solarY), false. This function does not apply any CoordinateBounds.

DEFAULT_COORDINATE_BOUNDS​

A CoordinateBounds of ±100 for universe coordinates and ±10 for solar coordinates.

NO_COORDINATE_BOUNDS​

A completely unbounded CoordinateBounds of ±∞ for universe coordinates and ±∞ for solar coordinates.