Is it possible to lerp between to matrices?

Sage
Posts: 1,199
Joined: 2004.10
Post: #1
I know this is a fairly fundamental question, but I'm curious if it's possible to lerp between two matrices. I know you can lerp two quaternions, so if worse comes to worst I can do that.

By lerp -- in case I'm using the wrong terminology, I mean:

Code:
float lerp( float amt, float a, float b )
{
    return ( amt * a ) + ( ( 1-amt) * b );
}

Is there an analog for matrix math?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
You can do scalar multiplication and matrix addition... so I don't se why not.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #3
I'll have to give it a shot. I figured it would work, but I wanted to check the hive mind.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #4
Thinking about it for a bit, it seems like things would get pretty screwy with rotation. You'll probably get some, if not a lot, of distortion while interpolating. Give it a try, though, and let us know how it goes. If it's a problem, it seems like it could be solved without too much trouble.
Quote this message in a reply
Member
Posts: 131
Joined: 2004.10
Post: #5
Just thinking about the topic, you'll run into issues. Say you have an identity matrix and a matrix that swaps y and z values. Now if you find the middle ground you end up with the following matrix...
Code:
{{1.0 0.0 0.0 0.0}
{0.0 0.5 0.5 0.0}
{0.0 0.5 0.5 0.0}
{0.0 0.0 0.0 1.0}}
The problem here is that both of the original matrices define a unit coordinate system. This one in the middle is not unit, so you've ended up adding a scale to the operation which I assume will be undesirable.

It's doable but you'll have to overcome some issues I think.
Quote this message in a reply
Member
Posts: 184
Joined: 2004.07
Post: #6
http://www.gamedev.net/community/forums/..._id=313474 has some useful information- 30 second google search!
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #7
Short answer? No. Smile

Long answer: the two matrices are orthogonal, and should remain as such during the lerp. However, rotation is a non-linear operation and will not remain orthogonal. And, corollary to Zekaric: if you have two matrices that are just rotated 180° on the Z axis, how should the LERP interpret that? By rotation? Scaling? A massive shearing operation on three axes? Smile

This is the reason that quaternions are so popular - they can be interpolated! Smile
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #8
Sounds good to me. Thanks for the info, fellas.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #9
Fenris Wrote:Short answer? No. Smile

I challenge this. As soon as I get home, I'm going to do my darnedest to prove you wrong. Grin
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
Yes, you can lerp matrices. No, it's not very helpful, for the reasons pointed out (rotations in particular don't remain rotations during a lerp).

For most applications, storing Quaternion orientation; Vector position; Scalar scale; gives you all the representative power you need, and that representation is both easy to interpolate and easy to convert to a matrix.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
I was thinking along those lines originally -- I was just wondering if there were a shortcut. So it goes!
Quote this message in a reply
Member
Posts: 47
Joined: 2004.07
Post: #12
I would say 'it depends'.... If your matrices are close together, it could very well work (it's quite common when skinning). If they are more than a bit apart, it's gonna blow.

Nicholas Francis
http://www.otee.dk
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Angles and Matrices and Whatnot merrill541 5 3,450 Jun 2, 2009 04:13 AM
Last Post: unknown
  Skewed Vertices with Quaternions, Matrices, and Good Ol' Trig Oddity007 4 3,585 May 12, 2009 03:13 PM
Last Post: Oddity007