Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
Good ideas at the time.

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


                                           

Rectagon

The particular rectangle that has some equivalence with a hexagon
  (+3, -1)
(+3, -1)
  [vote for,
against]

This Idea really needs a Computer:Game:Tools category. That's because when laying out the graphics for a game, this particular rectangle can be a useful tool.

Let's start with the specific and "regular" rectangle, also known as a "square". In games like dungeon adventures, squares are the common building block for the floor plans of the dungeons. That's mostly because it is so conventional to build walls at 90-degree angles that almost no one does it any other way.

Now while a grid of squares can cover the entirety of a flat surface ("tile the plane"), in terms of movement from one square to another, it is well known that moving diagonally lets you cover more distance than moving orthogonally, when whole squares are used as distance-measuring elements. Inside a structure, however, this is not usually a problem, because walls tend to prevent large diagonal movements.

Out in open fields, though, the walls aren't there, and so mapping tends to be done using hexagon grids. Hexagons can also tile a plane, and they offer more accurate distance-measurements, when moving at an angle. The center-to-center distance between a hexagon and each of its neighbors is the same (not true for a grid of squares).

The problem I wish to point out is that when developing games on a computer, the viewscreen is, at its finest scale, a grid of squares. It is difficult to create a grid of really smooth-edged hexagons on such a background-grid of squares --see link for an example that you could load into an image editor, and expand until you can see the pixels making up the hex grid. For that particular grid, I did not need "regular" hexagons (every side the same length, and every angle the same angle), but any serious game-developer could very easily need accurately-drawn regular hexagons.

The Rectagon is a proposed compromise solution to the problem. It has a very particular ratio of height to width --any other ratio is "just" an ordinary rectangle (except when it is a square).

To see how the Rectagon can be derived from a hexagon, consider the following ASCII sketch:
/|\ (pretend the lines meet at a point)
|-| (ignore the hyphen for the moment)
\|/ (pretend the lines meet at a point)
I added the interior vertical bars so that you can imagine some triangles (horizontal lines not provided in the sketch). If the upper two triangles are clipped off, they could be meshed against the lower two triangles (upper-left against lower-right, and upper-right against lower-left), and the result IS the Rectagon.

If that was done for every hexagon in a regular grid, the result would be a grid of Rectagons, and the key feature of the hex grid would be retained (same center-to-center distance between neighbors). It would look a great deal like an ordinary brick wall, except that bricks don't normally have the critical height- to-width ratio.

We can now compute that critical ratio, since we know exactly how to derive a Rectagon from a regular hexagon, which we assume every side had a length of ONE unit (any unit).

From the center of the hexagon to its upper corner is a distance of 1 unit (ditto to the bottom corner). If we now reference the hyphen in the sketch, and imagine it as a line going all the way across the middle of the hexagon, then we can see that since the lengths of the vertical sides are also 1 unit, the distance from the center to the place where we clip off the upper triangles is 1/2 unit. SO, when we move the two triangles to the bottom of the hexagon, we have that full unit of distance from the center to the bottom, plus that 1/2 unit of distance from center to the upper cut-off place, which means that the height of the Rectagon is exactly 1.5 units.

From the center to the upper-right corner is also 1 unit (note that sketch is not a REGULAR hexagon), and since the "drop" from that corner to the middle of the side, where the hyphen-line bisects it, is 1/2 unit, we have two sides of a right-angle triangle that lets us compute the third side (via Pythagorean Theorem) as being 1/2 of the square root of 3 (or "(sqrt(3))/2"), the distance from the center to the side. That means the full width of the hexagon (twice the computed distance) is sqrt(3) units, about 1.732 units. The Rectagon certainly has that width.

Thus the height-to-width ratio of a Rectagon is 1.5 to sqrt(3), exactly that ratio, and no other ratio. It is a unique rectangle. When we imagine every hexagon in a regular grid getting converted to a Rectagon in the manner described above, we note that the center-point of EVERY single hexagon needs to move down exactly the same distance (.25 unit), to reach the center of each new Rectagon. The net result is, the center-to- center distance between adjacent Rectagons is the same as on the hex grid. Which was the goal. (Okay, for the wise guys out there, I know you could have a grid of "vertical" Rectagons, instead of the longer-distance-is-horizontal thing described here. So the height-to-width ratio is sqrt(3) to 1.5, which, geometrically speaking, doesn't count as a significant difference.)

Now I understand that the grid of squares on a viewscreen isn't going to perfectly accommodate the exact ratio of 1.5 to sqr(3), but it is much easier to draw a brick-wall grid of rectangles that are that are "close enough" to the ideal, than it is to draw a grid of hexagons. And therefore this can be a useful tool in the game-designer's toolbox.

Vernon, Jan 20 2016

A grid of hexagons (not regular) http://www.nemitz.n...on/HexagonWeave.png
As mentioned in the main text. [Vernon, Jan 20 2016]

EVLU EVLU
This is a game I wrote a number of years ago, that uses a grid of regular hexagons. It can be downloaded from a link on that page. [Vernon, Jan 20 2016]

Quick sketch. http://cosketch.com/Saved/plCDwvzK
[scad mientist, Jan 20 2016]

Amit’s Game Programming Information : Hex grids http://www-cs-stude...p/gameprog.html#hex
[Loris, Jan 21 2016]

Hexagonal grid math http://www.gdreflec...onal-grid-math.html
[Loris, Jan 21 2016]

Rhombus tessellation http://www.supercol...ith-rhombus-pattern
Another pattern that might make for an interesting gaming grid [scad mientist, Jan 21 2016]

Rectagon "Life" http://www.nemitz.net/games
A pastime listed on a Menu on that page, involving several thousand Rectagons. Another pastime on the Menu, "Mine-Field Maze", also uses a grid of Rectagons, although it doesn't say so. [Vernon, Mar 18 2016, last modified Mar 31 2016]

[link]






       //And therefore this can be a useful tool in the game-designer's toolbox.//   

       Um, I'm not sure what tool is now there that wasn't already.   

       Hexagonal grids are already used in numerous games, in multiple projections. I'm reasonably confident the game developers involved have already done any maths necessary for that.
Loris, Jan 20 2016
  

       Rectangular simulation of hexes is baked, the game called Book Worm comes to mind. Not sure about this specific ratio though.
the porpoise, Jan 20 2016
  

       I made a sketch for you. [Quick sketch] The thing I don't like about hexagon grids (or rectagon grids) is that you can't move north/south at the same rate as east/west. Of course that's only a problem if people layout the overall map with square elements. If the map is more random then you can never travel straight anyway, so a hexagon grid is good.
scad mientist, Jan 20 2016
  

       [scad mientist], nice sketch; thanks. And it has a small advantage, in that after converting hexagons to rectagons in the way you portrayed it, the center of each is still in the same place as before.
Vernon, Jan 20 2016
  

       So given that the ratio you state is kind of self-evident from the basic geometry of the system, and is the first thing anyone wanting to use hexagons in a computer game derives, what is the invention here?
Loris, Jan 21 2016
  

       [Loris], the invention is that you can get the exact effect of a hex grid, in terms of movement-distances in various directions, without the complexity of actually drawing a hex grid. I'm fairly sure this is not WKTE, mostly because I've never seen anyone doing it (except me, in some games I'm not yet ready to release).
Vernon, Jan 21 2016
  

       The "Amit" link provided by [Loris] is extremely comprehensive and covers a lot of common game functions where hexes are concerned (coordinate systems, path-finding, etc). Hard to draw hexes? Plug in Amit's code.
the porpoise, Jan 21 2016
  

       [the porpoise], the links that I provided should show (especially the EVLU game) that I can do hexagons quite well (in that game, the all the contents of the cells on the board can be click-dragged in all directions; the board has the topology of the surface of a torus).   

       But the point is, hexagons are not actually NEEDED, because of the properties of the Rectagon.
Vernon, Jan 21 2016
  

       I see how you don' t need to draw hexagons, but don't you need all the other hexagon math for coordinates, pathfinding, finding neighbors, etc? I can see how this math would change somewhat, but it won't be as simple as a regular rectangular grid. E.g., assuming a brickwork layout, finding your row would be trivial, but finding your column would lean on hexagonal math. I suppose the nasty angles are gone in that example.
the porpoise, Jan 21 2016
  

       The idea is interesting to me since it looks at game layout from a perspective I haven't before. The rectagons also allow for more or larger text in each space in a hexagon topology.   

       While playing with this I was looking for a different pattern that might provide more uniform movement in more directions than a hex grid. I'm not sure such a thing is readily possible, but I did come upon a rhombus tessellation that might hold interesting potential for a game grid. [link]. This results in movement capabilities very similar to hexagons in the macro sense, but from each space it is only possible to move to 4 other spaces.   

       I'm not sure if a game could be created that would really benefit from this layout, but it at least might be an interesting gimmick to slightly differentiate a game.
scad mientist, Jan 21 2016
  

       When your bum gets shot off.... rectumagone (apologies - my mind is a free agent)
xenzag, Jan 21 2016
  

       [the porpoise], there are always other ways to do things. If I recall right (it has been a while), what I did for either hexagon or rectagon grids was to assign each cell a number in an array, and then created a table that was an array of groupings of neighboring cells. Arrays allow very quick lookups, regarding if a clicked move from one cell was legal (to an actual neighboring cell).
Vernon, Jan 21 2016
  

       Other similar tessellations (from a macro movement point of view) but with only three possible movements from each tile, would be to subdivide each rhombus into four identical right-angle triangles, or to tessellate the field with equilateral triangles.
pocmloc, Jan 21 2016
  

       [scad mientist], regarding an earlier anno that you wrote, I wager that if you twisted an overall hexagon grid slightly (by 15 degrees, I think), relative to standard east-west or north-south orientation, then east-west distances across the twisted grid could exactly equal north-south distances, across the twisted grid, when counting whole cells.   

       If I'm right, then the above will also be true of a twisted Rectagon grid.
Vernon, Jan 22 2016
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle