**0**

# Smooth interpolation between two matrices

###
#1
Members - Reputation: **534**

Posted 01 October 2012 - 04:24 AM

###
#2
Members - Reputation: **1116**

Posted 01 October 2012 - 04:35 AM

my blog (German)

###
#3
Members - Reputation: **534**

Posted 01 October 2012 - 04:53 AM

###
#4
Crossbones+ - Reputation: **7002**

Posted 01 October 2012 - 05:37 AM

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).Since it's 2D I don't need quaternions.

My game: Gnoblins

Developer journal about Gnoblins

Small goodies: Simple alpha transparency in deferred shader

###
#5
Members - Reputation: **534**

Posted 01 October 2012 - 06:16 AM

startAng + (endAng - strtAng) * tso 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.

###
#6
Members - Reputation: **532**

Posted 01 October 2012 - 06:16 AM

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,

*that*can be linearly interpolated without much concern.

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

###
#8
Crossbones+ - Reputation: **12539**

Posted 01 October 2012 - 09:15 AM

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.

###
#10
Crossbones+ - Reputation: **12539**

Posted 01 October 2012 - 11:17 AM

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.

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, 01 October 2012 - 11:17 AM.**