- assert(-radius <= x && x <= radius);
- assert(-radius <= y && y <= radius);
- return surface * SurfaceArea() + ToOffset(y) * SideLength() + ToOffset(x);
- }
- /// Convert coordinate into offset
- int ToOffset(int c) const {
- return c + radius;
- }
- /// The "radius" of the planet.
- int Radius() const {
- return radius;
+ assert(0 <= x && x <= sidelength);
+ assert(0 <= y && y <= sidelength);
+ return surface * TilesPerSurface() + y * SideLength() + x;