• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
cjcat2266

Quaternion Basics

14 posts in this topic

They are basically the usual stuff you can found everywhere without any proof/explanation. I have a few observations:

  1. The dot product is not part of quaternion algebra. Since quaternions are 4D vectors you can clearly define it in the usual way, but it is an additional structure.
  2. You have defined the conjugate as an "optimization" for the inverse in the unit quaternion case, but it is very important in quaternion algebra, They are for example used to define the norm of a quaternion |q| = sqrt( q * conjugate(q)) and to define multiplicative inverses q^-1 = conjugate(q)/(q*conjugate(q)). Indeed we have that q*conjugate(q) is the real number |q|^2 and thus q*(conjugate(q)/(q*conjugate(q)) = 1.

EDIT: Removed the first point after Alvaro's comment.

Edited by apatriarca
0

Share this post


Link to post
Share on other sites

I have always wondered wether there is a relation between quaternions and rotating phasors that can be used to make a more intuitive way of seeing how quaternions work.

 

A complex number: z = x + jy can basically be seen as a vector with a rotation and length:

 

z = r cos ? + j (r sin ?) = r e^(j?)    

 

Where:

 

r = sqrt(x^2 + y^2)     - The length

 

and:

 

? = arctan(y/x)    - The angle

 

You now have:

 

r e^(j?)

 

Now you can just multiply with another vector to get rotation:

 

r1 e^(j?1) * r2 e^(j?2) = r1 r2 e^(j(?1 + ?2))

 
Above, you will also change the length of the vector when you multiply, so we will just "remove" the r2 to multiply with unit length.
 
r1 e^(j(?1 + ?2))

      

Now you see that rotation really is the matter of finding the original length and angle, then just add the amount of radians you want to rotate.  Since this is the full rotation in one go, you need to add a time variable in there too.

 

In my DSP book, they define a complex exponential signal like this:
 
z(t) = A e^(j(w0 t + ?))     - It is basically the same formula as above

 

Where A is the amplitude, w0 is the frequency in radians, t is time and theta is the initial phase.

 

In my head, I see the amplitude as the length of the vector, i.e. the length of the line you draw from the centre to the point you want to rotate, and the phase as the initial angle of that point.  The frequency part doesn't really fit, but to me it just amounts to find the amount of rotation you want and find a time step you need to animate it properly in place.

 

By the way, the book defines the phasor itself to be:

 

X = Ae^j?    - Length and initial angle

 

and redefines the last formula to be:

 

z(t) = Xe^j(w0 t)

 

In other words you have the Amplitude and initial rotation multiplied with each small steps you want per time unit.  (The formula really shows radian frequency multiplied with time.)

 

I must admit that I am trying to understand the whole picture here myself, but I have such a strong feeling that there must be a much simpler way of visualising this relationship with quartenions somehow.  This example shows what happens in one dimension.  If you understand what is going on in one dimension, it must be easier to understand what is happening in all three dimensions.

 

I am sorry if I am way off here though...  It is just an idea I have had for a long time and want to find out more about. smile.png

Edited by aregee
0

Share this post


Link to post
Share on other sites

A complex signal is simply a function of the time which takes complex values. For each time step you have a complex number defined by that formula. Since the amplitude is a constant, that signal represents a complex number of fixed magnitude and different angle. The angle is equal to theta at time zero and then increase linearly. The frequency (actually the angular velocity) represents the rate of change of the angle. Since the initial angle (the phase) is constant, it can be extracted from the exponential, separating the constant part (your phasor) and the time varying part (an exponential with a fixed frequency). It has nothing to do with quaternions.

0

Share this post


Link to post
Share on other sites

They are basically the usual stuff you can found everywhere without any proof/explanation. I have a few observations:

  • The dot product is not part of quaternion algebra. Since quaternions are 4D vectors you can clearly define it in the usual way, but it is an additional structure.
  • You have defined the conjugate as an "optimization" for the inverse in the unit quaternion case, but it is very important in quaternion algebra, They are for example used to define the norm of a quaternion |q| = sqrt( q * conjugate(q)) and to define multiplicative inverses q^-1 = conjugate(q)/(q*conjugate(q)). Indeed we have that q*conjugate(q) is the real number |q|^2 and thus q*(conjugate(q)/(q*conjugate(q)) = 1.

Whether the dot product is an additional structure or not is debatable. As you point out, q * conjugate(q) is an important quantity (the square of the norm). This is a positive-definite quadratic form in the R-vector space of quaternions, and it naturally defines an inner product by writing

norm_squared(q + w) = norm_squared(q) + norm_squared(w) + 2 * inner_product(q, w)

The inner product defined that way is the same as the dot product of q and w as elements of R^4. So I wouldn't say it's an additional structure.
1

Share this post


Link to post
Share on other sites

A complex signal is simply a function of the time which takes complex values. For each time step you have a complex number defined by that formula. Since the amplitude is a constant, that signal represents a complex number of fixed magnitude and different angle. The angle is equal to theta at time zero and then increase linearly. The frequency (actually the angular velocity) represents the rate of change of the angle. Since the initial angle (the phase) is constant, it can be extracted from the exponential, separating the constant part (your phasor) and the time varying part (an exponential with a fixed frequency). It has nothing to do with quaternions.

 

First: I am not trying to argue with you in any way, I am trying to understand.

 

Isn't that what a rotation in graphics is too:  A fixed magnitude and a initial angle (the phase at time zero), then a rotation?  I know that the angular velocity (sorry for being imprecise) makes the phasor rotate round and round forever in the kind of signal I presented, but isn't that just the representation, as you are saying?  It is easy to rewrite the function I wrote to behave in the way that it stops at a given rotation in stead of rotating forever.  Instead of giving a time, you would say that you want the rotation to be done in a certain amount of time OR in small steps until you reach the angle of rotation you want?  In both cases complex notation is used too.  I kind of see some resemblance here, but I am absolutely aware that I may be completely wrong.  I probably am.  

 

Edit: Probably what you are saying is that my thought is closer to be using Euler angles than quternions?

 

I am not implying those are the same, by the way, just that I thought maybe it can be used somehow to help visualising and give an intuitive understanding of quaternions.

Edited by aregee
0

Share this post


Link to post
Share on other sites

Whether the dot product is an additional structure or not is debatable. As you point out, q * conjugate(q) is an important quantity (the square of the norm). This is a positive-definite quadratic form in the R-vector space of quaternions, and it naturally defines an inner product by writing


norm_squared(q + w) = norm_squared(q) + norm_squared(w) + 2 * inner_product(q, w)

The inner product defined that way is the same as the dot product of q and w as elements of R^4. So I wouldn't say it's an additional structure.

 

 

You are probably right, the quaternion algebra is a normed space and you can thus define an inner product in that way. And it is probably useful and worth defining anyway. 

0

Share this post


Link to post
Share on other sites

@aregee: I'm arguing we are speaking about different things. Signals are quantities varying in time, while quaternions represents a particular "state" (a transformation from one position to the other). In general a quaternion do not depends on any quantity (it is also true for complex numbers). It doesn't represent a process, there are no steps toward your final orientation.

 

You may have signals taking value in any set and you can then clearly have quaternion signals. You may also define the exponential function*. The exponential map is defined in this case from the 3D vector space (of imaginary quaternions for example) to the unit quaternions. You have that 

 

exp(v) = (cos(theta/2), sin(theta/2)*v/theta)

 

where theta=|v|. You can thus generalize most of what you have seen to the quaternion case. But the theory is actually mostly the same and it doesn't give any new insight.

0

Share this post


Link to post
Share on other sites

@aregee: I'm arguing we are speaking about different things. Signals are quantities varying in time, while quaternions represents a particular "state" (a transformation from one position to the other). In general a quaternion do not depends on any quantity (it is also true for complex numbers). It doesn't represent a process, there are no steps toward your final orientation.

 

You may have signals taking value in any set and you can then clearly have quaternion signals. You may also define the exponential function*. The exponential map is defined in this case from the 3D vector space (of imaginary quaternions for example) to the unit quaternions. You have that 

 

exp(v) = (cos(theta/2), sin(theta/2)*v/theta)

 

where theta=|v|. You can thus generalize most of what you have seen to the quaternion case. But the theory is actually mostly the same and it doesn't give any new insight.

 

I am trying to find an intuitive way to connect formulas with what is really happening with quaternion rotation, like not just accepting "it is how it works" kind of explanation.  I want to really understand it on a deeper level, but still intuitively.  I understand now what you are saying, and I agree with you.  I think I just need to spend a full day trying to wrap my head around quaternions.

 

This video is cheesy, but the best explanation I have found till now.

 

http://www.youtube.com/watch?v=KdW9ALJMk7s

0

Share this post


Link to post
Share on other sites

Though, as mentioned above, the material you discuss can be found elsewhere, I find your article a nice summation of aspects of quaternions applicable to game programming.

 

A comment on your description of SLERP: although you define the range of t, you do not mention the intent of a SLERP with regard to t. In the context of interpolating rotations, IMHO, you should add something like "With t varying linearly, SLERP provides..."

0

Share this post


Link to post
Share on other sites

Though, as mentioned above, the material you discuss can be found elsewhere, I find your article a nice summation of aspects of quaternions applicable to game programming.

 

A comment on your description of SLERP: although you define the range of t, you do not mention the intent of a SLERP with regard to t. In the context of interpolating rotations, IMHO, you should add something like "With t varying linearly, SLERP provides..."

 

Good call. I've added a short paragraph commenting on this property.

0

Share this post


Link to post
Share on other sites

About SLERP, this article is usually worth looking: http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/

 

By the way, the thing about SLERP is not that it interpolates through the shortest path, but the fact that it ensures constant angular velocity.

 

In fact using the formula of your explanation alone you are NOT ensuring that you take the shortest path. For SLERP to ensure the minimal path the interpolation must be done between quaternions in the same hyperhemisphere.  In order to do that, you need to test whether the dot product of both quaternions is negative and then, if so, negate one of them. And you can do that whether you use SLERP or NLERP.

0

Share this post


Link to post
Share on other sites

About SLERP, this article is usually worth looking: http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/

 

By the way, the thing about SLERP is not that it interpolates through the shortest path, but the fact that it ensures constant angular velocity.

 

In fact using the formula of your explanation alone you are NOT ensuring that you take the shortest path. For SLERP to ensure the minimal path the interpolation must be done between quaternions in the same hyperhemisphere.  In order to do that, you need to test whether the dot product of both quaternions is negative and then, if so, negate one of them. And you can do that whether you use SLERP or NLERP.

 

Thanks for the info. I edited the article a little bit to add that info in.

0

Share this post


Link to post
Share on other sites

 

They are basically the usual stuff you can found everywhere without any proof/explanation. I have a few observations:

  • The dot product is not part of quaternion algebra. Since quaternions are 4D vectors you can clearly define it in the usual way, but it is an additional structure.
  • You have defined the conjugate as an "optimization" for the inverse in the unit quaternion case, but it is very important in quaternion algebra, They are for example used to define the norm of a quaternion |q| = sqrt( q * conjugate(q)) and to define multiplicative inverses q^-1 = conjugate(q)/(q*conjugate(q)). Indeed we have that q*conjugate(q) is the real number |q|^2 and thus q*(conjugate(q)/(q*conjugate(q)) = 1.

Whether the dot product is an additional structure or not is debatable. As you point out, q * conjugate(q) is an important quantity (the square of the norm). This is a positive-definite quadratic form in the R-vector space of quaternions, and it naturally defines an inner product by writing

norm_squared(q + w) = norm_squared(q) + norm_squared(w) + 2 * inner_product(q, w)

The inner product defined that way is the same as the dot product of q and w as elements of R^4. So I wouldn't say it's an additional structure.

 

how would you derive this quaternion inner product using only quaternion arithmetic though?

0

Share this post


Link to post
Share on other sites

how would you derive this quaternion inner product using only quaternion arithmetic though?


The post you are responding to has the definition. But I'll make it explicit, to be more clear:

norm_squared(a) := a * conjugate(a)

inner_product(q,w) := (norm_squared(q + w) - norm_squared(q) - norm_squared(w)) / 2
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0