currently I'm dealing with the following problem. I am working with javascript and I cannot (and dont want to) use any third party .js libraries.
I am writing a function and I have two standard transformation matrices on the input - A and B:
var A = [
[a, c, e],
[b, d, f],
[0, 0, 1]
];
var B = [
[a, c, e],
[b, d, f],
[0, 0, 1]
];
and a theta value T between or equal to 0 and 1. The numbers a,b,c,d correspond to rotation and scaling and e and f are equal to x and y position.
I need to interpolate between these two matrices and I was wondering, what is the best approach (performance-wise) as this function will be called very often. I have already sorted out the x and y part using lerp. Now I'm wondering what would be the least intensive way to do this. These are the options I found so far:
- 1st Option - use quaternions and slerp - from what I found on the net and heard from my coleagues, this option involves a lot of computing. I am also not very familiar with this approach and I don't know how to implement it to suit this scenario.
- 2nd Option - decompose the two matrices, get the Translation, Rotation and Scale values for A and B and store them, then lerp by T these and compute the resulting matrix.
Is there any other approach maybe less CPU intensive I can use that I missed?