Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 08:00:27 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Properly normalizing a dual quaternion [SOLVED]
Pages: [1]
Print
Author Topic: Properly normalizing a dual quaternion [SOLVED]  (Read 2085 times)
TheSnidr
Level 1
*


View Profile
« on: April 19, 2014, 12:45:06 PM »

I'm having trouble with dual quaternions, and I believe it's because they're not properly normalized.

Say 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.
Halp?
« Last Edit: April 19, 2014, 10:02:05 PM by TheSnidr » Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #1 on: April 19, 2014, 02:30:40 PM »

I know very little about dual quaternions, but, like regular quaternions they are not commutative. There's no reason to expect Q to be the same as B.

The square root of a dual number is pretty simple to work out:

(a + ɛ b)^2 = a^2 + 2 ɛ a b = c + ɛ d

i.e.
c = a^2
d = 2 a b


a = sqrt(c)
b = d / 2 / sqrt(c)


So
sqrt(c + ɛ d) = sqrt(c) + ɛ d / 2 /sqrt(c)

Wikipedia has the formula for dividing by a dual number, which you also need for normalization.
Logged
TheSnidr
Level 1
*


View Profile
« Reply #2 on: April 19, 2014, 10:01:43 PM »

Thanks for your reply!
I believe Q = A * B * A' is the dual quaternion equivalent of q = a * b / a for real numbers. The conjugate and the inverse of a unit dual quaternion is the same thing.

I figured out the biggest part of my problem, and it's quite stupid really - I was only conjugating the real part of the dual quaternion. Also conjugating the dual part fixed the whole problem!

EDIT:
Typo
« Last Edit: April 19, 2014, 11:57:28 PM by TheSnidr » Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #3 on: April 20, 2014, 01:19:09 AM »

I believe Q = A * B * A' is the dual quaternion equivalent of q = a * b / a for real numbers. The conjugate and the inverse of a unit dual quaternion is the same thing.
No No NO quaternions and the like do not behave like real numbers.

Suppose A = i and B = j. Then

Q = i * j * (-i)
  = k * i * -1
  = -j


which is not the same as B.
Logged
TheSnidr
Level 1
*


View Profile
« Reply #4 on: April 21, 2014, 11:36:42 AM »

I believe Q = A * B * A' is the dual quaternion equivalent of q = a * b / a for real numbers. The conjugate and the inverse of a unit dual quaternion is the same thing.
No No NO quaternions and the like do not behave like real numbers.

Suppose A = i and B = j. Then

Q = i * j * (-i)
  = k * i * -1
  = -j


which is not the same as B.
Err... Please read up on quaternions and dual quaternions. If A is a unit quaternion, doing that will be the equivalent of first rotating B around A', and then rotate it around A, which effectively is the opposite rotation of A'. You basically rotate B an angle around an axis, and then back again to the starting position. Which means that Q should always be equal to B when the quaternion/dual quaternion is normalized.

Correct or not, I get the exact results I want when doing it this way. I multiply a bone with the conjugate of the parent bone to get the local orientation, then I multiply that with the frame's change in orientation, and then I multiply this with the parent's orientation again. If there is no local change in orientation, I always end up with the orientation I started with.

EDIT:
*Hits head*
Sorry, you're right. I had the order off in my post. What I'm actually doing is:
Q = B * A' * R * A
Where R is the change in local orientation. If R is identity, I end up with Q = B since AA' = 1 for unit quaternions
« Last Edit: April 21, 2014, 10:22:14 PM by TheSnidr » Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic