While rotations and mod calculation and such for hex and triangular grids are nowhere near priority at this point, implementing direction calculation for Identify should be a pretty simple task.
Here's a relatively in-depth examination of how directions can be defined for said grids (which should also double as an effective explanation for anyone who wants to understand how directions are defined and can be identified for hexagonal and triangular grids), as well as example spaceships travelling in said directions, and their displacements on a square grid, such that those can be used for calculating the directions in these cases:
----
Hexagonal Grids
Unlike the square grid which has four orthogonal and four diagonal directions, the hexagonal grid has six orthogonal and six diagonal directions.
----
Orthogonal
We define the orthogonal direction through an analogy with the square grid. Starting from the center of a hexagon, an infinite ray drawn in one of these directions will always intersect the edges of the grid at their very centers, and will never intersect a vertex.
Code: Select all
x = 1, y = 1, rule = B/S
o!
[[ VIEWONLY X 15 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 32 0 10 ]]
Code: Select all
x = 1, y = 1, rule = B/SH
o!
[[ VIEWONLY X 15 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 32 0 10 ]]
For sufficiently non-chaotic ships such as the one shown in the below example, their direction can be found to be orthogonal by examining the history trail - a gentle 120-degree zigzag with two different directions indicates an orthogonal ship.
By the prior definition, the following six directions would be considered Orthogonal:
Code: Select all
x = 25, y = 25, rule = B2/S3H
3bo5bo$b2o8b2o$bo3bo3bo3bo$o2bo8bo2bo$5b2o3b2o$2bobo8bobo$4bo9bo3$obo
16bobo$4bo13bo$bo2bo14bo2bo$bobo17bobo$2bo2bo14bo2bo$6bo13bo$3bobo16bo
bo3$10bo9bo$9bobo8bobo$13b2o3b2o$9bo2bo8bo2bo$11bo3bo3bo3bo$12b2o8b2o$
15bo5bo!
On a square grid, these are reported as (1,0), (1,1), (0,-1), (-1,0), (-1,-1) and (0,1).
----
Diagonal
While it can be clearly seen that the diagonal direction would by definition be exactly halfway between two given orthogonal directions, we can again define the diagonal direction through the same method as was used previously: an infinite ray traced from the center of a cell out to infinity in one of these directions will always intersect the two opposite vertices of every cell it visits.
Code: Select all
x = 1, y = 1, rule = B/S
o!
[[ VIEWONLY X 15 Y -15 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 32 -32 10 ]]
Code: Select all
x = 1, y = 1, rule = B/SH
o!
[[ VIEWONLY X 15 Y -10 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 20 -20 10 ]]
For sufficiently non-chaotic ships such as the one shown below, their direction can be found to be diagonal by examining the history trail - a more dramatic boundary with three different directions and "period" of 4 indicates a diagonal ship.
The following six directions would, via the definition provided at the top, be considered Diagonal:
Code: Select all
x = 34, y = 36, rule = B2/S2H
4$9bo$9b2o$10bo2$9bobobo2$3b2o2bo9bo2b2o$4b2o14b2o$7bo11bo2$7bo13bo4$
9bo13bo2$11bo11bo$9b2o14b2o$9b2o2bo9bo2b2o2$17bobobo2$20bo$20b2o$21bo!
On a square grid, these are reported as (1,-1), (2,1), (1,2), (-1,1), (-2,-1) and (-1,-2).
----
Hexagonal Conclusion
As a result, for hexagonal grids, using square grid coordinates, for any integer n:
- spaceships travelling with a displacement of (n,0), (n,n), (0,-n), (-n,0), (-n,-n) or (0,n) should be reported as travelling orthogonally,
- spaceships travelling with a displacement of (n,-n), (2n,n), (n,2n), (-n,n), (-2n,-n) or (-n,-2n) should be reported as travelling diagonally
- and spaceships travelling in a direction that does not fit any of these criteria should be considered as travelling oblique.
Triangular Grids
For triangular rules, we can also define directions. As LifeViewer displays hexagonal and triangular grids in positions where they form a geometrical dual compound when superimposed, it is advisable to define triangular grid directions by what the hexagonal grid directions correspond to were they superimposed on the triangular grid. Conveniently, the definitions this approach yields also appear to match up with the ray-casting definitions defined earlier.
As the behaviour of handling triangular rules on a square grid is considerably different from hexagonal, the square-grid displacements and what they correspond to on the triangular grid will also differ.
Again, the triangular grid has six each of orthogonal and diagonal directions.
----
Orthogonal
Through the ray-casting approach, this would be the Orthogonal direction:
Code: Select all
x = 1, y = 1, rule = B/S
o!
[[ VIEWONLY X 15 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 32 0 10 ]]
Code: Select all
x = 1, y = 1, rule = B/SL
o!
[[ VIEWONLY X 15 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 32 0 10 ]]
Through applying the "overlay" or "ray-casting" definitions, these six directions would be considered Orthogonal:
Code: Select all
x = 12, y = 9, rule = 369/25/3LV
$6.B$3.2A.B.2A$.2B.2B.2B.2B$.A.B5.B.A$.A.B5.B.A$.2B.2B.2B.2B$3.2A.B.2A
$6.B!
[[ THEME Blues ]]
On a square grid, these displacements correspond to (1,-1), (2,0), (1,1), (-1,1), (-2,0) and (-1,-1).
----
Diagonal
Barring extrapolation/interpolation from the orthogonal directions, the raycasting definition shows this to be our diagonal direction:
Code: Select all
x = 1, y = 1, rule = B/S
o!
[[ VIEWONLY X 15 Y -15 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW 0 0 32 -32 10 ]]
Code: Select all
x = 1, y = 1, rule = B/SL
o!
[[ VIEWONLY X 10 Y -5 ZOOM 16 GRID GRIDMAJOR 0 THEME 6 COLOR ARROW 0 192 0 ARROW -0.25 -0.25 24.5 -8.5 10 ]]
Through interpolation or applying the "overlay" or "ray-casting" definitions, these six directions would be considered Diagonal:
Code: Select all
x = 14, y = 12, rule = B19y/SL
2$6bobo$2bo9bo$bo11bo3$bo11bo$2bo9bo$6bobo!
On a square grid, these displacements (for these period 2 ships specifically - I know of no period 1 spaceships that travel in this direction, and doubt they can exist) correspond to (0,-2), (3,-1), (3,1), (0,2), (-3,1) and (-3,-1).
----
Triangular Conclusion
As a result, for hexagonal grids, using square grid coordinates, for any integer n:
- spaceships travelling with a displacement of (n,-n), (2n,0), (n,n), (-n,n), (-2n,0) or (-n,-n) should be reported as travelling orthogonally,
- spaceships travelling with a displacement of (0,-2n), (3n,-n), (3n,n), (0,2n), (-3n,n) or (-3n,-n) should be reported as travelling diagonally
- and spaceships travelling in a direction that does not fit any of these criteria should be considered as travelling oblique.
----
The displacement shown at the top of Identify still currently uses the square grid format, which of course doesn't make any sense in cases such as these. However, I'd say it should be kept until further support for hexagonal and triangular grids is supported, at which point basically all coordinate values that users can see may be hexagon/triangle-specific (perhaps something like
this).