animation - Plotting a quadratic equation in Delphi/Lazarus -


i trying animate object's position using quadratic equation rapid-start-slow-stop kind of movement.

this available in delphi xe6 using delphi xe2 , lazarus , have created own animation handling system works great actually.

i have linear formula , half-sinus formula, want quadratic formula.

the half-sinus formula move object rapidly @ start , slows down, want more exaggerated curve, rapid @ start , slows down lot , halts.

unfotunately have no code available since code looking for.

i have used our dear friend mr google, no luck finding information can comprehend.

basically needed formula gives floating point number rangin 0 1.

i take delta of position of object needs moved , multiply formula needed.

in animation system have 2 values regarding animation process:

var currentpos, resolution: single; 

the value "currentpos" represents position of formula. instance sinus can apply "currentpos" angle, or x axis of plot, , "resolution" max angle (360 degrees) or whole plot view in x axis.

the current formula have found far quadratic equation following:

formula := (-b+(sqr(power10(b, 2)-4*(a*c))))/(2*a); 

where in formula put in value of "currentpos"?

or real question, have gotten whole mathematical process wrong?

you want equation in unknown x is:

  1. quadratic in x.
  2. has value of 0 when x = 0.
  3. has value of 1 when x = 1.
  4. varies rapidly when x close 0 , not vary rapidly when x close 1.

your quadratic therefore of form: 1 - (1-x)2.

this has derivative 2 when x = 0 , 0 when x = 1.

you'll need translate input variable in range 0 1. once done feed above formula x.

if want use different exponents can replace exponent. instance cubic version be: 1 - (1-x)3.

in code might write this:

function outpoly(x: real, exponent: integer): real; begin   result := 1 - intpower(1-x, exponent); end; 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -