<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Amit's Site - Latest Comments in Amit’s Thoughts on Grids</title><link>http://blobs.disqus.com/</link><description>Amit's game programming and other pages</description><atom:link href="https://blobs.disqus.com/amits_thoughts_on_grids/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 18 Feb 2019 20:54:07 -0000</lastBuildDate><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-4343996340</link><description>&lt;p&gt;You are a god among men. Thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">haleyysz</dc:creator><pubDate>Mon, 18 Feb 2019 20:54:07 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-4270090128</link><description>&lt;p&gt;This is a cool layout!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Fri, 04 Jan 2019 18:42:58 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-4269615844</link><description>&lt;p&gt;I have already posted about this in the hex tutorial, but this is a more relevant place. With a picture now, too!&lt;/p&gt;&lt;p&gt;&lt;a href="http://roguetemple.com/z/gifs/trianglemap.svg" rel="nofollow noopener" target="_blank" title="http://roguetemple.com/z/gifs/trianglemap.svg"&gt;http://roguetemple.com/z/gi...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;A cool way to implement a triangular map in a game, . Fits in a 2D array &lt;br&gt;with no wasted space! The cells adjacent to (x,y) are always (y,x), &lt;br&gt;(y,x-1), (y+1,x). Reflect ∇s in the blue edge to see how it works. Found&lt;br&gt; it several years ago, but it does not seem to be known.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Zeno Rogue</dc:creator><pubDate>Fri, 04 Jan 2019 13:25:33 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-4004176805</link><description>&lt;p&gt;See the "Square to Hexagon" section of the page. A hexagonal grid slides the squares over. You can think of this as a change in basis vectors x=(1,0) y=(0,1) to x=(1,0) y=(1,1/2) or x=(1,1/2) y=(1,0). You can slide them back by setting y += x/2 or x += y/2 (or -= depending on how your grid is set up)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Tue, 24 Jul 2018 13:03:43 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-4003702683</link><description>&lt;p&gt;Is there a way to convert a hex grid to square grid? any particular algorithm?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MrJox</dc:creator><pubDate>Tue, 24 Jul 2018 07:22:20 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-3631278391</link><description>&lt;p&gt;Thank you!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Fri, 24 Nov 2017 12:11:59 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-3631278221</link><description>&lt;p&gt;Glad it helped! Although you can do something with weirdly shaped pentagons, I don't see games using them. There are only three shapes for "regular" tilings: &lt;a href="https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons" rel="nofollow noopener" target="_blank" title="https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons"&gt;https://en.wikipedia.org/wi...&lt;/a&gt; and all the other shapes have to be tiled irregularly. I think once you get to that point it might be easier to think of it as a graph (see the "voronoi" section on this page) instead of a grid.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Fri, 24 Nov 2017 12:11:50 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-3631138998</link><description>&lt;p&gt;Hello Mr Amit, thank you so much for your great references. I want to pull together once and for all a decent map generator for all of my future games array starting with my_game[0] ... :)&lt;br&gt;Have tryed having pentagon shaped grid cells ? any comparison with hex?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">m sorin</dc:creator><pubDate>Fri, 24 Nov 2017 10:14:14 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-3328829515</link><description>&lt;p&gt;I keep coming back to this blog month after month and I'm amazed each time by the detailed explanation. Can't believe this is over 10 years old!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lazar Ljubenovic</dc:creator><pubDate>Sun, 28 May 2017 12:09:25 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-3289034394</link><description>&lt;p&gt;Modern Chess is indeed "Western", having been transformed from shatranj in southern Europe.&lt;/p&gt;&lt;p&gt;More detail here: &lt;a href="https://en.wikipedia.org/wiki/Chess#1200.E2.80.931700:_Origins_of_the_modern_game" rel="nofollow noopener" target="_blank" title="https://en.wikipedia.org/wiki/Chess#1200.E2.80.931700:_Origins_of_the_modern_game"&gt;https://en.wikipedia.org/wi...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It was not until 1960s that modern chess became popular in India &lt;a href="https://en.wikipedia.org/wiki/Manuel_Aaron" rel="nofollow noopener" target="_blank" title="https://en.wikipedia.org/wiki/Manuel_Aaron"&gt;https://en.wikipedia.org/wi...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;That said, the "Eastern" shatranj indeed favors faces&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Phil</dc:creator><pubDate>Thu, 04 May 2017 16:32:00 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2789937865</link><description>&lt;p&gt;Thanks! I wrote it over ten years ago so I'm trying to figure out what I did wrong here.&lt;/p&gt;&lt;p&gt;1. This does seem wrong. It doesn't even make sense, as i,j are vectors. I think it will end up being (0.5*ix, 0.33*jy) and (1.0*ix, 0.66*jy). However, I should work this out on paper to make sure.&lt;/p&gt;&lt;p&gt;2. The notation I used was terrible, and when I rewrite this page I'll do a better job. It's the x,y components of the i,j vectors. It would've been clearer if I wrote i.x, i.y, j.x, j.y.&lt;/p&gt;&lt;p&gt;3. I've since learned that I should never ever write that something is “easy”, because whatever was easy to me back when I was writing it is not easy for me now, nor necessarily easy for the reader. I believe what you have to do is look at the equation that computes world coordinate x,y from the matrix ix,iy,jx,jy and the grid coordinate u,v. You can solve for u,v  by inverting the matrix. I never did work out the details on this page :(&lt;/p&gt;&lt;p&gt;4. I think you're right! I will correct the text.&lt;/p&gt;&lt;p&gt;Part of the problem is that I never did end up using triangle grids for a real project, so I never worked out the bugs :(  I've updated the page.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Mon, 18 Jul 2016 15:15:14 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2783691464</link><description>&lt;p&gt;Hey. Fantastic guide, just what I was looking. I have a few questions though.&lt;/p&gt;&lt;p&gt;1.  "The L triangle face center is (0.25*i, 0.25*j) from the lower left vertex. The R triangle face center is (0.75*i, 0.75*j) from the lower left vertex."&lt;/p&gt;&lt;p&gt;I think those values should be 0.33 and 0.66, not 0.25 and 0.75 respectively. That is, if the triangles are equilateral, of course.&lt;/p&gt;&lt;p&gt;2. I am very confused about the values you wrote as ix, iy, jx, and jx. What are they exactly? Do you mean those vectors (i and j) multiplied by world coordinates (x,y)? But that's the formula to calculate world coordinates, so i can't use them to calculate them. I think I am misunderstanding this terribly.&lt;/p&gt;&lt;p&gt;3. "To convert from world coordinates to triangle vertices is easy. Solve for (u, v) using algebra." I don't know what I am supposed to solve for (u,v).&lt;/p&gt;&lt;p&gt;4. "I believe it’s R when frac(u) + frac(v) &amp;gt;= 0.5."&lt;/p&gt;&lt;p&gt;Since the Left-Right edge runs between (0,1) and (1,0) vertices, right through (0.5,0.5) centre of the sheered square, I believe it's  frac(u) + frac(v) &amp;gt;= 1, that's correct.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alivender</dc:creator><pubDate>Thu, 14 Jul 2016 17:45:07 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2360230124</link><description>&lt;p&gt;Broken again. I have found it on the internet, just an FYI.&lt;br&gt;Thx for the great stuff!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">DÁvidám Horváth</dc:creator><pubDate>Sat, 14 Nov 2015 19:10:47 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2311324213</link><description>&lt;p&gt;The counting parts section isn't very clear for me...Where could I find a more detailed explanation?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jafeth Díaz Castañeda</dc:creator><pubDate>Fri, 16 Oct 2015 19:00:32 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2114871454</link><description>&lt;p&gt;Interesting — thanks. I put that link in the More section because I haven't studied it yet. I'm guessing there are additional properties that make rectangles different from parallelograms in that context, but I don't really know.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Fri, 03 Jul 2015 13:13:18 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2113787132</link><description>&lt;p&gt;Great read, thanks.  One observation; in the last paragraph you state 'Mathematicians have found five types of grids in 2D space: squares, triangles, hexagons, rectangles, and parallelograms.'  Actually, a rectangle is technically a parallelogram (as is a square).  I believe the 5th shape, discounting the rectangle, that could be made into a grid is an isosceles trapezoid.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Kelly</dc:creator><pubDate>Thu, 02 Jul 2015 22:11:41 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2080264286</link><description>&lt;p&gt;Is it okay if we discuss there?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">skaps</dc:creator><pubDate>Mon, 15 Jun 2015 12:56:03 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2080263689</link><description>&lt;p&gt;I sent you an email regarding the same.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">skaps</dc:creator><pubDate>Mon, 15 Jun 2015 12:55:42 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2080005932</link><description>&lt;p&gt;What trouble are you having? These algorithms should work the same in most any language.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Mon, 15 Jun 2015 10:18:27 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-2079559757</link><description>&lt;p&gt;Hey, great work with the detailed explanations. I wanted to implement a similar algorithm in java but am having trouble with it. Was wondering whether anyone has tried that? Or if you've tried it, Amit?&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">skaps</dc:creator><pubDate>Mon, 15 Jun 2015 02:37:12 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-1813421854</link><description>&lt;p&gt;Hi Mark, sorry, I don't have any pointers for more advanced uses of grids. I've collected just enough for the way I use grids in games, and haven't looked at more.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Fri, 23 Jan 2015 14:21:09 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-1806373013</link><description>&lt;p&gt;Thank you for all the work about grids. Do you have anything on floating point coordinates and mapping them to grids? I know this can become complicated if the point coordinates are ends of segments that make up structures. Snap rounding nerds to be then used on the vertices of these structures (i.e. "Stable Snap Rounding" by John Hershberger).&lt;/p&gt;&lt;p&gt;Another issue is pairing functions like Szudzik's for grids. With the single integer from the pairing one then could construct a hash table for the points on the grid.&lt;/p&gt;&lt;p&gt;Do you have any pages or pointers to good and easy to understand articles on these topics?&lt;/p&gt;&lt;p&gt;Thanks again.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark Szl</dc:creator><pubDate>Wed, 21 Jan 2015 09:14:36 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-1698573835</link><description>&lt;p&gt;You are a god among men. Thanks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">BenH</dc:creator><pubDate>Mon, 17 Nov 2014 23:01:21 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-1561723862</link><description>&lt;p&gt;Hi &lt;a href="http://mkv25.net" rel="nofollow noopener" target="_blank" title="mkv25.net"&gt;mkv25.net&lt;/a&gt; games, take a look here: &lt;a href="http://www.redblobgames.com/grids/hexagons/#map-storage" rel="nofollow noopener" target="_blank" title="http://www.redblobgames.com/grids/hexagons/#map-storage"&gt;http://www.redblobgames.com...&lt;/a&gt; ; you can see that a rectangle map in axial hex coordinates is a "parallelogram" in q, r coordinates, where 0 ≤ q + r/2 &amp;lt; N&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">amitp</dc:creator><pubDate>Wed, 27 Aug 2014 11:16:34 -0000</pubDate></item><item><title>Re: Amit’s Thoughts on Grids</title><link>http://www-cs-students.stanford.edu/~amitp/game-programming/grids/#comment-1557481410</link><description>&lt;p&gt;Question: what's the best way to cover a rectangle with hexagons? Assuming I'm storing hexagons in axial q, r coordinates...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">mkv25.net games</dc:creator><pubDate>Sun, 24 Aug 2014 18:26:32 -0000</pubDate></item></channel></rss>