sclass OCRCompass { IBWIntegralImage image; Pt center; // point we're looking at double radius = 16; // radius of circle int sensorFootprint = 4; // size of each "pixel" (rectangle) to grab int steps = 12; // how many segments of circle (=steps/2 line orientations). should be even int blur; // blur width double[] values; // brightnesses at each point (low=foreground) L sensors() { ret squaresAroundCircle(center, steps, radius, sensorFootprint); } void compute { values = mapToDoubleArray(sensors(), r -> image.getPixelAverage(r)); } void ensureComputed { if (values == null) compute(); } double mostLikelyAngle() { ensureComputed(); indexOfMaxEntryInDoubleArray(values); ret twoPi()/steps; } }