• 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
Volgogradetzzz

Smooth interpolation between two matrices

9 posts in this topic

Hi. I have two 2D matrices with scale, rotation, skew, translation. How can I interpolate between them. Say, I want to know matrix at time 0.5. I know it's possible because tools such as Flash IDE can construct intermediate frames based on start and end frames.
0

Share this post


Link to post
Share on other sites
If you *really* want to interpolate the matrices, it will (as you seem to have noticed) look funny. What you really want to do, is to interpolate all components on their own and reconstruct the resulting matrix afterwards. For rotation interpolation, have a look at quaternions and the SLERP interpolation scheme. Translation and scale can be interpolated using standard linear interpolation. Don't know about skew though, I never actively used it...
2

Share this post


Link to post
Share on other sites
Yes, I meant interpolation of "states", i.e. rotation, scale etc. Since it's 2D I don't need quaternions. And yes, the trickiest part for me is to deal with shear. I investigate bit deeper and found that tool that I use (Flash IDE) use strange skew matrix algorithm. So the problem for me is to decompose correct values. And I think this forum can't help me in this particular question. So, thanks everyone :).
0

Share this post


Link to post
Share on other sites
[quote name='Volgogradetzzz' timestamp='1349088828' post='4985705']
Since it's 2D I don't need quaternions.
[/quote]
If you want to do spherical interpolation (rotation), then you should use quaternions. A 2d space is just a plane in a 3d space, therefore you can use 3d math (just set one component to zero).
0

Share this post


Link to post
Share on other sites
Yes, but it's a pointless exhaustion of system resources. In 2D interpolation is simple
[CODE]startAng + (endAng - strtAng) * t[/CODE]
so you can't persuade me to use quaternions :).

BTW I solve a problem. Flash uses it's own skew matrix. I found an algorithm. Flawless victory.
1

Share this post


Link to post
Share on other sites
Darn, beaten to the punch (I arrived rather late). Slerp and quaternions are so ludicrously simple that it makes my head hurt thinking about how much my head originally hurt when I'd convinced myself it was something hard! You should definitely get used to them, as familiarizing yourself with quaternions will make more than just (rotation) matrix interpolation easier. Also, quaternions work in 2D just as well as 3 (after all, the Z component will only change if the two control points have different z components which isn't the case in your model).

Also note that you can't directly interpolate rotation matrices - or, well, you can but it's ugly. If you don't care about smooth interpolations, then you can always do a (1.0-A)*M1+A*M2 [where 0<=a<=1] linear interpolation... but that's horrid for just about any practical use for rotation matrices. As for your translation and scale, [i]that[/i] can be linearly interpolated without much concern.

Oof, I just realized all this was said above. Still, it's good info.
0

Share this post


Link to post
Share on other sites
Using a linear interpolation between two angles will result in something that looks off, even if it's for 2D space. If people could linearly interpolate theta and have it look correct, then they could linearly interpolate phi as well.
-1

Share this post


Link to post
Share on other sites
Linear interpolation of angles in 2D gets a bit tricky when you want to go from 10 degrees to 350 degrees. If you do it naively, you'll go around the long end.

The true analog of quaternions for 2D rotations is complex numbers. Just as with quaternions, rotations are represented by unit-length complex numbers, and you can slerp between them just fine. The conversion from angle to complex number is cos(alpha)+sin(alpha)*i. When you want to apply the rotation to a point (x,y), interpret the point as x+y*i and multiply it by the complex number.
0

Share this post


Link to post
Share on other sites
Of course, in 2D you often have cases where you don't restrict yourself to one rotation, and you wish to interpolate between -pi rad and 11pi rad doing several full rotations as part of it.
0

Share this post


Link to post
Share on other sites
[quote name='luca-deltodesco' timestamp='1349107780' post='4985784']
Of course, in 2D you often have cases where you don't restrict yourself to one rotation, and you wish to interpolate between -pi rad and 11pi rad doing several full rotations as part of it.
[/quote]

That can be done in 3D as well, but it's not a commonly desired behavior. When it is, chances are the situation is best described by an initial attitude and an angular velocity to be integrated. This also works in 2D. Edited by alvaro
0

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