Takes a matrix of 4-element quaternion vectors, unifies their hemispherical signs to handle the double-cover property, and finds the geometric median rotation using Weiszfeld's algorithm via the pracma library.

median_quaternion(q_matrix)

Arguments

q_matrix

A list of numeric vectors, where each element is a c(w, x, y, z) quaternion.

Value

A normalized 4-element numeric vector representing the median quaternion.