Jump to content


Photo

Easing question *solved*


  • Please log in to reply
4 replies to this topic

#1 djk164

djk164

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 10 August 2012 - 06:38 PM

I know this is possible in game maker, but I am not a math wizard or anything, so here it is.
I have been looking on easing stuff, and have found that it makes everything a lot better. I was wondering how might you make this in game maker?:
Posted Image


thanks!

Edited by djk164, 11 August 2012 - 09:49 PM.

  • 0

#2 djk164

djk164

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 11 August 2012 - 02:03 AM

Ok, i think i found an formula
ax^3+bx^2+cx+d
But i am not sure if this is correct. As I am only in high school.
Could someone tell me if this is correct?
  • 0

#3 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1098 posts
  • Version:GM7

Posted 11 August 2012 - 02:12 AM

Based on your picture, it looks like it could be the first part of a cubic function with a local max and min (the formula you are asking about). Your picture could also be a compound function of a parabola, and then a square root function (although I'd have to play with that quite a bit before it can match the above graph). This kind of depends on what you plan on using your sketch for...

Edited by smash ball, 11 August 2012 - 02:13 AM.

  • 1

#4 Yourself

Yourself

    The Ultimate Pronoun

  • Retired Staff
  • 7341 posts
  • Version:Unknown

Posted 11 August 2012 - 03:47 AM

Your picture could also be a compound function of a parabola, and then a square root function


"And then a"? That's not a mathematical operation I've ever heard of. If you mean the sum of a square root and a quadratic, it's definitely not that (the pictured function has two flat spots, the sum of a square root and a quadratic can only ever have one flat spot at most).

If, instead, you mean that the pictured function could be a piecewise square root and a quadratic, then no, it still couldn't be that. The square root function isn't capable of producing any flat spots.

If you meant that the pictured function could be the product of a square root function and a quadratic, then I can say that it could sort of maybe be that. You can generate a similar shape, but it'll never be quite right.

Now, since we're talking about ease curves, this actually looks pretty similar to the BackEase curve that shows up in WPF. The basis function for that is:



For some constant a. Now, the specific curve we're given above is actually the reverse of this and would be generated by the following:



For the curve in the OP, you'd set a to about 0.4 to get the same shape.

I should also mention that you can get very close to the same shape with a cubic polynomial. Just for fun, let's figure out how we can get the best equivalent cubic approximation. First, let's narrow down the cubic. We can notice that our function, f, has a few special properties:

f(0) = 0
f(1) = 1
f'(0) = 0 (it's flat at t = 0; remember I'm working with the flipped version of the function).

Using these equations, we can find all the cubics that have these same properties. It turns out they're all of the form:



Now, to the fun part. We want to minimize the difference between g(t) and f(t) over the interval [0, 1]. One way of measuring how "different" the two functions are is with the mean square error:



Now, what we want to do is, for a given value of a, find the value of b that minimizes that error. That gives us the following equation:



By the Leibniz integral rule, we can move that derivative inside the integral, which helps simplify some of the algebra. However, the algebra's still pretty tedious, so I'll spare you that and jump straight to the result. After we crank out all the algebra, we can solve for b:



Anyway, there are other metrics you could choose to minimize. For example, you could try to minimize the maximum difference between the two functions. That's actually considerably more difficult in this case even though it doesn't involve any integration!
  • 2

#5 djk164

djk164

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 11 August 2012 - 09:49 PM

wow! that is a long reply
none of the middle stuff makes any sense, but at least the last thing does!
Thank you!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users