Skip to content

Commit

Permalink
Fix JS layout (according to new ESLint rules)
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 19, 2023
1 parent f0dbf34 commit ad2f8e5
Show file tree
Hide file tree
Showing 2 changed files with 398 additions and 393 deletions.
64 changes: 32 additions & 32 deletions app/assets/javascripts/monotile/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,81 @@ const hr3 = 0.8660254037844386;
const ident = [1, 0, 0, 0, 1, 0];

Check warning on line 6 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'ident' is assigned a value but never used

function pt(x, y) {
return { x: x, y: y };
return { x: x, y: y };
}

function hexPt(x, y) {
return pt(x + 0.5 * y, hr3 * y);
return pt(x + 0.5 * y, hr3 * y);
}

// Affine matrix inverse
function inv(T) {
const det = T[0] * T[4] - T[1] * T[3];
return [T[4] / det, -T[1] / det, (T[1] * T[5] - T[2] * T[4]) / det,
-T[3] / det, T[0] / det, (T[2] * T[3] - T[0] * T[5]) / det];
};
const det = T[0] * T[4] - T[1] * T[3];
return [T[4] / det, -T[1] / det, (T[1] * T[5] - T[2] * T[4]) / det,
-T[3] / det, T[0] / det, (T[2] * T[3] - T[0] * T[5]) / det];
}

// Affine matrix multiply
function mul(A, B) {
return [A[0] * B[0] + A[1] * B[3],
A[0] * B[1] + A[1] * B[4],
A[0] * B[2] + A[1] * B[5] + A[2],
return [A[0] * B[0] + A[1] * B[3],
A[0] * B[1] + A[1] * B[4],
A[0] * B[2] + A[1] * B[5] + A[2],

A[3] * B[0] + A[4] * B[3],
A[3] * B[1] + A[4] * B[4],
A[3] * B[2] + A[4] * B[5] + A[5]];
A[3] * B[0] + A[4] * B[3],
A[3] * B[1] + A[4] * B[4],
A[3] * B[2] + A[4] * B[5] + A[5]];
}

function padd(p, q) {

Check warning on line 34 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'padd' is defined but never used
return { x: p.x + q.x, y: p.y + q.y };
return { x: p.x + q.x, y: p.y + q.y };
}

function psub(p, q) {

Check warning on line 38 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'psub' is defined but never used
return { x: p.x - q.x, y: p.y - q.y };
return { x: p.x - q.x, y: p.y - q.y };
}

// Rotation matrix
function trot(ang) {
const c = cos(ang);
const s = sin(ang);
return [c, -s, 0, s, c, 0];
const c = cos(ang);

Check failure on line 44 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'cos' is not defined
const s = sin(ang);

Check failure on line 45 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'sin' is not defined
return [c, -s, 0, s, c, 0];
}

// Translation matrix
function ttrans(tx, ty) {
return [1, 0, tx, 0, 1, ty];
return [1, 0, tx, 0, 1, ty];
}

function rotAbout(p, ang) {

Check warning on line 54 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'rotAbout' is defined but never used
return mul(ttrans(p.x, p.y),
mul(trot(ang), ttrans(-p.x, -p.y)));
return mul(ttrans(p.x, p.y),
mul(trot(ang), ttrans(-p.x, -p.y)));
}

// Matrix * point
function transPt(M, P) {

Check warning on line 60 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'transPt' is defined but never used
return pt(M[0] * P.x + M[1] * P.y + M[2], M[3] * P.x + M[4] * P.y + M[5]);
return pt(M[0] * P.x + M[1] * P.y + M[2], M[3] * P.x + M[4] * P.y + M[5]);
}

// Match unit interval to line segment p->q
function matchSeg(p, q) {
return [q.x - p.x, p.y - q.y, p.x, q.y - p.y, q.x - p.x, p.y];
};
return [q.x - p.x, p.y - q.y, p.x, q.y - p.y, q.x - p.x, p.y];
}

// Match line segment p1->q1 to line segment p2->q2
function matchTwo(p1, q1, p2, q2) {

Check warning on line 70 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'matchTwo' is defined but never used
return mul(matchSeg(p2, q2), inv(matchSeg(p1, q1)));
};
return mul(matchSeg(p2, q2), inv(matchSeg(p1, q1)));
}

// Intersect two lines defined by segments p1->q1 and p2->q2
function intersect(p1, q1, p2, q2) {

Check warning on line 75 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'intersect' is defined but never used
const d = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);
const uA = ((q2.x - p2.x) * (p1.y - p2.y) - (q2.y - p2.y) * (p1.x - p2.x)) / d;
return pt(p1.x + uA * (q1.x - p1.x), p1.y + uA * (q1.y - p1.y));
const d = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);
const uA = ((q2.x - p2.x) * (p1.y - p2.y) - (q2.y - p2.y) * (p1.x - p2.x)) / d;
return pt(p1.x + uA * (q1.x - p1.x), p1.y + uA * (q1.y - p1.y));
}

const hat_outline = [

Check warning on line 81 in app/assets/javascripts/monotile/geometry.js

View workflow job for this annotation

GitHub Actions / ESLint (JS)

'hat_outline' is assigned a value but never used
hexPt(0, 0), hexPt(-1, -1), hexPt(0, -2), hexPt(2, -2),
hexPt(2, -1), hexPt(4, -2), hexPt(5, -1), hexPt(4, 0),
hexPt(3, 0), hexPt(2, 2), hexPt(0, 3), hexPt(0, 2),
hexPt(-1, 2)
hexPt(0, 0), hexPt(-1, -1), hexPt(0, -2), hexPt(2, -2),
hexPt(2, -1), hexPt(4, -2), hexPt(5, -1), hexPt(4, 0),
hexPt(3, 0), hexPt(2, 2), hexPt(0, 3), hexPt(0, 2),
hexPt(-1, 2),
];
Loading

0 comments on commit ad2f8e5

Please sign in to comment.