Skip to content

Commit

Permalink
remove a suspicious special case
Browse files Browse the repository at this point in the history
this is part of the orient/lock problem #6
honestly i'm not sure how this works
but i removed a bit of suspicious logic for the negative case
and i would not expect to need a special case for rotating arrays
  • Loading branch information
gordonwoodhull committed Oct 8, 2023
1 parent 19490fd commit 14ac193
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/lib/puzzle/grids/penrosegrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,23 @@ export class PenroseGrid extends AbstractGrid {
}

getPipesPath(tile, index, rotations) {
let directions = this.DIRECTIONS;
rotations = rotations % directions.length;
if (rotations < 0) {
directions = [...directions.slice(rotations), ...directions.slice(0, rotations)];
} else if (rotations > 0) {
directions = [...directions.slice(-rotations), ...directions.slice(0, -rotations)];
}
rotations = rotations % this.NUM_DIRECTIONS;
const directions = [...this.DIRECTIONS.slice(-rotations), ...this.DIRECTIONS.slice(0, -rotations)];
const symbol_portion = 0.7;
let bezier = true;
if (symbol_portion > 1) bezier = false;
tile = this.polygon_at(index).rotate(tile, rotations);
const { center } = this.p3rhombs[index];
const { direction_to_index } = this.polygon_at(index);
while(rotations < 0) rotations += directions.length;
return [
`M 0 0`,
...directions.map((direction) => {
if ((direction & tile) === 0) return null;
// use the rotated direction for geometry

let dirind = direction_to_index.get(direction);
dirind = (dirind + rotations) % 4;
while (dirind < 0) dirind += 4;
dirind = (dirind + rotations) % this.NUM_DIRECTIONS;
direction = directions[dirind];
const { neighbour, oppositeDirection } = this.find_neighbour(index, direction);
const A = this.getTileSymbolEnd(index, direction, symbol_portion);
Expand Down

0 comments on commit 14ac193

Please sign in to comment.