Documente Academic
Documente Profesional
Documente Cultură
9 January 2006
Squares
1 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Hexagons
2 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Triangles
Grid Parts #
3 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Uses in games
4 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
5 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Squares to Hexagons
6 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
7 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Squares to Triangles
Coordinate Systems #
8 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Square Grids
9 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Hexagon Grids
10 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
11 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Triangle Grids
12 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Face
Edge
Vertex
13 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Algorithms
Shape
Relationship
Square Hexagon Triangle
Neighbors: (u,v,L)
(u,v) (u,v,R)
(u,v) (u,v+1) (u,v-1,R)
(u,v+1) (u+1,v) (u-1,v,R)
(u+1,v) (u+1,v-1)
(u,v-1), (u,v-1) (u,v,R)
(u-1,v) (u-1,v) (u,v+1,L)
(u-1,v+1) (u+1,v,L)
(u,v,L)
Borders: (u,v,L)
(u,v) (u,v,E)
(u,v) (u,v,N) (u,v,S)
(u,v+1,S) (u,v,E) (u,v,W)
(u+1,v,W) (u+1,v-1,W)
(u,v,S) (u,v-1,N) (u,v,R)
(u,v,W) (u-1,v,E) (u,v+1,S)
(u,v,W) (u+1,v,W)
(u,v,E)
Corners: (u,v) (u,v) (u,v,L)
(u+1,v+1) (u+1,v,L) (u,v+1)
(u+1,v) (u,v,R) (u+1,v)
(u,v) (u+1,v-1,L) (u,v)
14 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Shape
Relationship
Square Hexagon Triangle
(u-1,v,R) (u,v,R)
(u,v+1) (u,v,L) (u+1,v+1)
(u-1,v+1,R) (u+1,v)
(u,v+1)
(u,v,N) (u,v,S)
(u,v+1) (u,v,L)
Joins: (u,v,W) (u,v) (u,v-1,R)
(u,v)
(u-1,v) (u,v,E) (u,v,E)
(u+1,v) (u,v,R)
(u,v,S) (u,v) (u,v,L)
(u,v)
(u,v-1) (u,v,W) (u,v,W)
(u,v) (u,v,L)
(u-1,v+1) (u-1,v,R)
(u,v,W)
(u,v+1,W)
Continues: (u,v,W) (u,v-1,W)
(u,v+1,W) No edges
(u,v-1,W) continue (u,v,E)
straight in a (u+1,v-1,E)
(u,v,S) hexagonal (u-1,v+1,E)
(u+1,v,S) grid
(u-1,v,S) (u,v,S)
(u+1,v,S)
(u-1,v,S)
(u,v,N) (u,v,W)
(u+1,v,L) (u,v+1)
Endpoints: (u,v,W) (u-1,v+1,R) (u,v)
(u,v+1)
(u,v) (u,v,E) (u,v,E)
(u,v,R) (u+1,v)
(u,v,S) (u+1,v,L) (u,v+1)
(u+1,v)
(u,v) (u,v,W) (u,v,S)
(u-1,v+1,R) (u+1,v)
(u,v,L) (u,v)
15 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Shape
Relationship
Square Hexagon Triangle
(u,v,L)
Touches: (u,v)
(u,v) (u-1,v)
(u,v) (u-1,v,R)
(u-1,v+1)
(u,v) (u,v,L)
(u,v-1) (u,v-1,R)
(u,v,R)
(u-1,v-1) (u,v-1,L)
(u+1,v)
(u-1,v) (u-1,v-1,R)
(u+1,v-1)
(u-1,v,L)
(u,v)
(u,v,L)
Protrudes: (u,v,W) (u,v)
(u,v) (u-1,v,E) (u,v,W)
(u,v,W) (u-1,v,N) (u,v,S)
(u,v,S) (u,v-1,E)
(u,v-1,W) (u,v,R) (u,v-1,W)
(u-1,v,S) (u+1,v-1,N) (u-1,v,S)
(u+1,v-1,W) (u-1,v,E)
(u,v,E)
(u,v,L)
Adjacent: (u-1,v+1,R) (u,v)
(u,v) (u-1,v,R) (u,v+1)
(u,v+1) (u-2,v+1,R) (u+1,v)
(u+1,v) (u+1,v-1)
(u,v-1) (u,v,R) (u,v-1)
(u-1,v) (u+2,v-1,L) (u-1,v)
(u+1,v-1,L) (u-1,v+1)
(u+1,v,L)
Relations
16 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Face Edge
0,0 0,0,S
0,0 0,0,W
0,0 0,1,S
0,0 1,0,W
1,0 1,0,S
1,0 1,0,W
1,0 1,1,S
1,0 2,0,W
Implementation
17 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
def corners(face)
u, v, side = face
case side
(u,v,L)
(u,v+1) (u+1,v) when :L
(u,v) [[u, v+1], [u+1,
v], [u, v]]
(u,v,R) when :R
(u+1,v+1) [[u+1, v+1], [u+1,
(u+1,v) (u,v+1) v], [u, v+1]]
end
end
Coordinate Transformations #
18 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
Squares
Hexagons
x ix jx u
y = iy jy v
x = ix * u + jx * v
y = iy * u + jy * v
19 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
# Face center
x = hexagon_narrow_width * u
y = hexagon_height * (u*0.5 + v)
20 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
when :R
x += hexagon_wide_width * 0.5
end
u = x / hexagon_narrow_width
v = y / hexagon_height - u * 0.5
Triangles
x ix jx u
y = iy jy v
21 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
More #
22 of 23 07/15/2016 03:13 PM
Amits Thoughts on Grids http://www-cs-students.stanford.edu/~amitp/gam...
23 of 23 07/15/2016 03:13 PM