quaternionNorm function
The measured pose of the capture platform over the scene clock. Opcode 0x22.
Not the FourdgsCamera record, which is a viewing suggestion a reader may ignore. This is where the sensors were. The Euclidean norm of a quaternion, computed without squaring the components first.
A component near the top of the double range squares to infinity, so the naive sum reports an infinite norm for a rotation whose norm is finite and whose direction is perfectly good. Section 5.15.4 refuses "zero or non-finite norms" — a statement about the quaternion, not about the arithmetic used to measure it. Dividing by the largest magnitude first makes the sum safe.
Implementation
double quaternionNorm(List<double> q) {
double scale = 0.0;
for (final v in q) {
final m = v.abs();
if (m > scale) scale = m;
}
// Left for the caller to refuse, with the message it words for its own record.
if (!scale.isFinite || scale == 0.0) return scale;
double sum = 0.0;
for (final v in q) {
final u = v / scale;
sum += u * u;
}
return scale * math.sqrt(sum);
}