Jump to content

Matrix.Lerp goes backwards??


JCPalmer
 Share

Recommended Posts

Unless I am interpreting what the gradient arg to Matrix.Lerp wrong, it seems to go backwards.  I changed it to this:

public static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix {
    var result = Matrix.Zero();

    for (var index = 0; index < 16; index++) {
        result.m[index] = startValue.m[index] + ((endValue.m[index] -  startValue.m[index]) * gradient);
    }

    return result;
}

The higher the gradient, the closer to endValue, right?  The process before was:

result.m[index] = startValue.m[index] * gradient + endValue.m[index] * (1.0 - gradient);

The title of the last PR was fixing Lerp.  I really thought this was a great improvement.  I could never get the bone interpolater I am working on with the now DecomposeLerp.  The new one is also much faster. 

But, if 10 was a start value, 20 the end, & .2 the gradient, then the answer should be:

10 + ((20 - 10) * .2) or 12, not

(10 *.2) + (20 * (1 - .2)) or 18

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...