Q:

Properly drawing a Penrose tiling using the pentagrid method

As part of my work, I create tools for artists to make various types of patterns for artistic purposes. I am trying to make a tool to create a Penrose tiling and I would like to use the pentagrid method of generating it, as it seems like the easiest way to allow the user to arbitrarily scale and translate the plane and still generate a nice random aperiodic tiling that easily stretches to infinity in any direction. Whereas using something like inflation or deflation becomes problematic when the user decides to scale the tile size down or translate by a large amount in any direction.
Given that, I've found several references on the how to generate a tiling from a pentagrid, such as these:

Pentagrids and Penrose 
The Empire Problem in Penrose Tilings 
Penrose Tiling 
Penrose Tilings Tied Up in Ribbons

They've been incredibly helpful, but I feel like I'm missing a step. I'm able to generate the pentagrid:

But when I attempt to generate the tiles, I end up with tiles that are separated:

I'm working in Swift and I'm generating the vertexes of each tile by doing the following at each intersection point:
var vertexes: [CGPoint] = []
for i in 0..<testPts.count {
    var nextVertex = intersectionPt
    for gridIndex in 0..<numGrids {
        let normal = e [ gridIndex ]
        let k = ceil((testPts [ i ] • normal) - gamma [ gridIndex ])
        nextVertex += k * normal
    }
    vertexes.append(nextVertex)
}

The testPts array contains 4 points - one in each face of the pentagrid that has a vertex at the intersection point. The e array contains the normals for each direction of the pentagrid. The gamma array contains the offsets of each grid in the pentagrid. Values in gamma are between -1.0 and 1.0.
Is this the expected result? Some of the references I've read have made vague statements about needing to move the tiles together (without suggesting how to do that), while others have seemed to indicate that they'll all fall into the correct positions.
If they do need to be moved together, is there a particular algorithm to do that?
If they don't need to be moved together, then what have I missed or misunderstood?

A:

Well I think I figured it out. The key is to keep track of which intersections of which grid lines are associated with each tile. Choose a starting tile and say that it is aligned. Then take each of the 4 tiles that were generated from the previous and next intersections of the 2 intersecting grid lines and move them towards the current tile until they touch. Then do the same for each tile you just moved, etc., until you've aligned all the tiles. In code it looks something like this (after adding the first tile to the queue): 
    while (!queue.isEmpty) {
        // get the front element of the queue
        let startingTile = queue [ 0 ]
        queue.remove(at: 0)

        // find the (up to) 4 tiles that are adjacent to it
        let adjacentTiles = startingTile.unalignedAdjacentTiles()

        // for each tile we found
        for adjacentTile in adjacentTiles {
            // move it to touch this tile
            let offset = startingTile.minimumOffsetTo(adjacentTile)
            adjacentTile.realign(by: offset)

            // mark it as aligned
            adjacentTile.aligned = true

            // add it to the queue
            queue.append(adjacentTile)
        }
    }

Doing that, I get results like this:

