Need help with math

BlitzMax Forums/BlitzMax Programming/Need help with math

Tachyon(Posted 2013) [#1]
My brain is not working tonight.

I need the math for moving between two points: accelerating until halfway, then decelerating to the end point.

Thanks in advance to the math whiz that throws me the answer!


Derron(Posted 2013) [#2]
Just calculate the distance between the two points (remember - they have a 90° angle in common - so just a²+b²=c². a = abs(y1-y2), b = abs(x1-x2) ... )

Now just:
if distance < startDistance/2 then accelerate else decelerate


bye
Ron


Brucey(Posted 2013) [#3]
How's about this fun page ? :-)


Tachyon(Posted 2013) [#4]
Ah, Brucy- you are awesome. Yep, "quartic easing in/out" is what I needed. Thanks Derron for the suggestion.


Derron(Posted 2013) [#5]
@Brucey

nice finding.

Hmm ... did a x-quadratic and y=sinus - and the movement wasn't a straight line (small sinus wave hickup on one coordinate direction).

@Tachyon:
The formulas brucey gave are just for acceleration-variations. You still need to know the position where to move to - and therefor you need to split your 2 points into 2 different segments (a and b when thinking of hypothenuse, cathetis)... Think the formulas are used to have get a factor of the already moved distance.


PS: never thought that the English language does not distinct between both cathetis (in German we have "Kathede" and "Ankathede" which is more distinctive than "longer / shorter cathetus").


bye
Ron


Floyd(Posted 2013) [#6]
That all sounds unreasonably complicated. The page of Actionscript examples is for one dimension, but that's all you need for a straight line.

Just pick a method and use it to transition from source and target x values, and also between source and target y values.

For the accelerate and decelerate case it's probably simplest to do this twice, from source to midpoint and then midpoint to target.


John G(Posted 2013) [#7]
Sine waves for acceleration/deceleration are nice.


Derron(Posted 2013) [#8]

That all sounds unreasonably complicated.



Think you wrote about my post (I assume it ...). The thing you describe is the same. (although my "a and b" are distances while your "source and target x values" are points which are the basement of the distances).

Like said, the calculations given in bruceys link are just "curves". Curves which can be used to calculate factors of deltamovement of (in this case it is a sum of deltas...). Just things you get teached at school (area below curves/functions...)

bye
Ron