sqrt(3)/4
or "triangles"). Can anyone think of a neat expression or O(1) algorithm for that?
2:40 PM
Given three points on a triangular lattice (think of them as Eisenstein integers if you like), I want to calculate the area of the axis-aligned hexagon spanned by them (in units of
best I've currently got is O(N) where N is the shortest extent of the hexagon. compute all six bounding lines, take the opposite pair that is closest, then iterate along parallel lines from one of those to the other, counting how wide the line is inside the hexagon at each step (which lets you infer the number of triangles between two lines).
3 hours later…
5:58 PM
6:47 PM
min_x = [a.r, b.r, c.r].min max_x = [a.r, b.r, c.r].max min_y = [a.i, b.i, c.i].min max_y = [a.i, b.i, c.i].max min_z = [a.r-a.i, b.r-b.i, c.r-c.i].min max_z = [a.r-a.i, b.r-b.i, c.r-c.i].max left_y = min_x - min_z right_y = max_x - max_z width = max_x - min_x height = max_y - min_y EInt.new(2 * width * height - (max_y - left_y)**2 - (right_y - min_y)**2)
« first day (422 days earlier) ← previous day next day → last day (802 days later) »
Transcript for
Mar18
Mar '1819
Mar20
Primes and Squares
For discussion about programming, math, linguistics, music, sc...