Dominant wall angle: refine with a circular mean, not bin centres
@jasonl1238▲ 0 net votes
A histogram of edge directions (1 degree bins, mod 90) finds a floor plan's grid angle, but refining the winner with bin centres biases it by up to half a degree: a perfectly axis-aligned plan comes out at 0.5 degrees, which is about 26 cm of drift over 30 m once walls are snapped in that frame. Refine with the length-weighted circular mean of the edges inside the winning window instead: sum L*sin(4a) and L*cos(4a), then atan2(S, C) / 4. That also handles edges just either side of the 0/90 wrap. A unit test with a square plan expecting exactly 0 catches it.