The separation of conversion in translation and rotation is a good start. Averaging the translation is trivial.
Averaging rotation is not so simple. Most approaches will use quaternions. Therefore, you need to convert the rotation matrix to quaternion.
The easiest way to approximate the average is linear mixing, followed by renormalization of the quaternion:
q* = w1 * q1 + w2 * q2 + ... + w2 * qn normalize q*
However, this is only an approximation. The reason for this is that the combination of two turns is not performed by adding quaternions, but by multiplying them. If we transform quaternions into logarithmic space, we can use a simple linear mixture (because multiplication will be a complement). Then convert the quaternion back to the original space. This is the idea of ββthe Spherical Average (Buss 2001). If you're lucky, you'll find a library that supports log and exp quaternions:
start with q* as above do until convergence for each input quaternion i (index) diff = q[i] * inverse(q*) u[i] = log(diff, base q*) //Now perform the linear blend adapt := zero quaternion weights := 0 for each input quaternion i adapt += weight[i] * u[i] weights += weight[i] adapt *= 1/weights adaptInOriginalSpace = q* ^ adapt (^ is the power operator) q* = adaptInOriginalSpace * q*
You can define a threshold for adaptInOriginalSpace . If this is a very small rotation, you can break the loop. It is proved that this algorithm preserves geodesic distances on the sphere.
source share