11 Replies - 253 Views - Last Post: 23 June 2013 - 05:13 AM Rate Topic: -----

#1 thewhiteaussie  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 5
  • Joined: 22-June 13

Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 06:22 PM

Quaternion concatenation is noncommutative. That is

qa * qb ≠ qb * qa


However

q-1 * q = q * q-1 = Iq


where q-1 is the inverse of q and Iq is the identity quaternion. VQS concatenation is also noncommutative:

TA_B * TB_C ≠ TB_C * TA_B


Where TA_B represents a VQS transformation. Now, we find the inverse of TA_B like so:

TA_B-1 = TB_A


My question is, is the concatenation of a VQS with its inverse commutative? Ie, is the following statement correct?

TA_B * TB_A = TB_A * TA_B = IVQS


Where IVQS is the identity VQS. With the implementation Iím using Iím finding

T -1 * T = IVQS, whereas
T * T -1 ≠ IVQS


This seems incorrect; both sould return IVQS.

Here is the implementation of VQS Inverse and concatenation functions I'm using:

//--------------------------------------------------------------------------------
//		VQS Concatenation
//--------------------------------------------------------------------------------
VQS VQS::operator*(const VQS& rhs) const
{
	VQS result;

	//Combine translation vectors
	result.v = q.Rotate(rhs.v) * s + v;

	//Combine quaternions
	result.q = q * rhs.q;

	//Combine scales
	result.s = s * rhs.s;

	//Return result
	return result;

}	//End: VQS::operator*()


//--------------------------------------------------------------------------------
//		Returns inverse VQS
//--------------------------------------------------------------------------------
VQS Inverse(const VQS& other)
{
	VQS temp;

	//Inverse scale
	temp.s = 1.0f / other.s;

	//Inverse quaternion
	temp.q = Inverse(other.q);

	//Inverse vector
	temp.v = temp.q.Rotate(-other.v) * temp.s;

	return temp;

}	//End: Inverse()



Is This A Good Question/Topic? 0
  • +

Replies To: Is the concatenation of a VQS with its inverse commutative?

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: -4
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 08:46 PM

And you haven't researched this?

This post has been edited by ButchDean: 22 June 2013 - 08:48 PM

Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10186
  • View blog
  • Posts: 37,613
  • Joined: 27-December 08

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 09:06 PM

In both cases, the multiplicative identity should be returned. A Quaternion inverse is defined to be its conjugate divided by the magnitude squared: q^{-1} = q*/(|q|^{2}).

It really doesn't look like that's what you're doing in your function. Then again, this is my first time researching Quaternions, so you might be doing something fancy I haven't seen. Given that your code isn't working though, either this isn't the case or you're implementing it incorrectly.

Either way, simple is usually better. I'd just stick with the known formula.
Was This Post Helpful? 0
  • +
  • -

#4 thewhiteaussie  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 5
  • Joined: 22-June 13

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 09:29 PM

I neglected to mention, the quaternion class I'm using has been thoroughly tested so Inverse(q) does indeed return q-1. The issue is I don't think the Inverse(VQS) function is returning the correct translation vector.To the best of my knowledge, line 37 does indeed represent the v-component of the inverse of a VQS, given by

1/s(q-1(-v)q)

Was This Post Helpful? 0
  • +
  • -

#5 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: -4
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 09:35 PM

How did you thoroughly test the code? Is this code yours?
Was This Post Helpful? 0
  • +
  • -

#6 thewhiteaussie  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 5
  • Joined: 22-June 13

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 10:14 PM

Good question. The Quaternion class is someone else's work. The VQS class is my own. I'm fairly certain the issue does not lie with the Inverse(quaternion) and Rotate() functions, but rather my approach for calculating the inverse of a VQS, specifically the translation component. I'm not sure why this is happening as I've pretty much just followed the known formula.

I guess to simplify my question: Refer to the code. Assume all methods for the quaternion and vector classes are correct. Is the 'Inverse(const VQS&)' function correct?
Was This Post Helpful? 0
  • +
  • -

#7 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10186
  • View blog
  • Posts: 37,613
  • Joined: 27-December 08

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 10:27 PM

I'd be interested to see a runnable sample, along with a basic example of numbers you've crunched (with the work). That should give us a good idea of exactly where the problem is occurring. If I had to guess, I'd say you're not rotating correctly.
Was This Post Helpful? 2
  • +
  • -

#8 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: -4
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 10:28 PM

The code has already given you the answer by not working. I would have to do a bit of research and debugging to work out why it isn't working, which is your job, not mine.

The fact that you have taken someone else's regular quaternion code and tried to 'layer' VQS on top of it is different from writing specific VQS code, and it wouldn't surprise me if that is your problem.

[edit]

Oh! You've also asked the question on GameDev.

Anyway, as you can see from this paper VQS structures are similar but not the same as quaternions, as I was alluding to earlier. I'm not sure if you quite understand that.

This post has been edited by ButchDean: 22 June 2013 - 10:45 PM

Was This Post Helpful? 0
  • +
  • -

#9 thewhiteaussie  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 5
  • Joined: 22-June 13

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 10:52 PM

Ok thanks everyone. This question was more about the theory. I'm just about convinced my math is correct, but I think you're right macosxnerd101. I probably need to crunch some more numbers to try to find out whats going on.
Was This Post Helpful? 0
  • +
  • -

#10 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10186
  • View blog
  • Posts: 37,613
  • Joined: 27-December 08

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 22 June 2013 - 11:06 PM

Your understanding of the theory seems to be good. Your implementation of it is what's causing something to go awry. Good luck debugging! :)
Was This Post Helpful? 0
  • +
  • -

#11 thewhiteaussie  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 5
  • Joined: 22-June 13

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 23 June 2013 - 12:57 AM

SOLVED.

You were right macosxnerd101, it was the rotation function. It turns out the quaternion was not normalized and so did not represent a rotation. Fixed by ensuring VQS.q was normalized on construction.

Thanks for you help :)
Was This Post Helpful? 3
  • +
  • -

#12 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: -4
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Is the concatenation of a VQS with its inverse commutative?

Posted 23 June 2013 - 05:13 AM

Well done! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1