DDS: stop the principal-axis iteration once the axis is a fixed point

A power-iteration step that gives back the same axis bit for bit gives
it back on every later step, so stopping there keeps the output. Kept
only if the timings show a gain.
This commit is contained in:
vangel76 committed 2026-11-16 00:00:28 +01:00
1 parent e22ccf3511
commit 203f225562
1 file changed
+8 -1
+8 -1
View File
@@ -235,7 +235,14 @@ fn principal_endpoints(colours: &[[f32; 3]]) -> ([f32; 3], [f32; 3]) {
if !len.is_normal() {
break;
}
axis = next.map(|v| v / len);
let normalised = next.map(|v| v / len);
// A step that returns the same axis, bit for bit, returns it on every later step too:
// stopping there gives the very axis the remaining steps would. Kept only if timing
// shows the comparison pays for itself.
if normalised.map(f32::to_bits) == axis.map(f32::to_bits) {
break;
}
axis = normalised;
}
axis
};