问题
I'm having trouble with dual quaternions, and I believe it's because they're not properly normalized. A, B and A' are dual quaternions where the latter is conjugated. When doing this: Q = A * B * A' I should theoretically always end up with Q = B if A and B are properly normalized. But in some cases, I don't, and it's completely messing up my whole skeletal hierarchy.
Many pages show that the norm of a dual quaternion is ||Q|| = sqrt(QQ'), but that means taking the square root of a dual number, and I have no idea how to do that. So right now I'm just dividing the whole thing by the length of the real part.
I've been searching around for days, but I still have yet to find a good code example on how to use dual quaternions. I feel I know the theory pretty well, but I still can't get it to work.
回答1:
Not too difficult. Of interest for computer graphics are only unit dual quaternions, i.e. ||Q|| = 1. This leads to:
QQ' = (R, D)(R*, D*) = (RR*, RD* + DR*) = (1, 0)
Q = dual quaternion. R = real part, D = dual part. You see, for unit dual quaternions the dual part vanishes. You need only to calculate the magnitude for the real part. So the problem is reduced to calculating the magnitude of a simple quaternion. And that is calculated analogous as it is done for complex numbers:
||R|| = sqrt(r1^2+r2^2+r3^2+r4^2)
(r1 - r4 are the components of the 4D vector R)
Now just divide the R/||R|| and D/||R|| and you have your normalized Q.
回答2:
I'm recently studying dual quaternion and just came across the same question, I'll try to give my answer, correct me if anything is wrong.
To normalize a dual quaternion, say Q=a+eb, we can just divide it by ||Q||. We need to calculate the norm of Q, this can be done with the following formula,
Then we can calculate the normalization by
回答3:
From glm source code:
template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> normalize(tdualquat<T, P> const & q)
{
return q / length(q.real);
}
I checked the operator/
implementation. It just divides both quaternions with a float.
来源:https://stackoverflow.com/questions/23174899/properly-normalizing-a-dual-quaternion