Re: Phix / pGui Rosetta example : animate_pendulum2.exw

new topic     » goto parent     » topic index » view thread      » older message » newer message

Beat you to it. (Got a little bit frustrated with my current project saying you have $7, so spend $124 of that...)

Sourced a recalc of the velocity[1]:

    if newlen!=len then 
        len = newlen 
        atom tmp = 2*g*len*(cos(angle)) 
        velocity = iff(tmp<0?0:sqrt(tmp)*sign(velocity)) 
    end if 

and moved

    velocity += dt*delta  
    angle += dt*velocity  

from redraw_cb into timer_cb, where it should have been all along.

Grab a fresh copy from https://bitbucket.org/petelomax/phix/src/default/demo/rosetta/animate_pendulum2.exw

Pete

[1]: Internally I have also made sqrt(-1) now report an error rather than yield -nan.

EDIT: also made it use openGL and changed the colours.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu