# Search the Community

Showing results for tags 'animation acceleration'.

• ### Search By Tags

Type tags separated by commas.

### Forums

• GreenSock Forums
• GSAP
• Banner Animation
• Jobs & Freelance
• Flash / ActionScript Archive
• GSAP (Flash)
• TransformManager (Flash)

### Product Groups

• Club GreenSock
• TransformManager

• Examples
• Showcase

• Products
• Plugins

### Categories

• Learning Center
• Blog

### Categories

• ScrollTrigger Demos

### Categories

• CodePen Challenges

• 0 Replies

• 0 Reviews

• 0 Views

Found 1 result

1. ## Accelerated motion algorithm. Perhaps you can turn that into a Tween?

You asked for a demo posted to the forums on Twitter, so here it is. The important bit is this function: const calcAccel = (x, v, maxA, dt) => { if(dt === 0) return 0; const signX = (x < 0)?-1:1; const a = signX * (Math.sqrt(Math.abs(1 + (2 * x) / (maxA * dt * dt))) * maxA - (v * signX) / dt - maxA); return Math.min(maxA, Math.max(-maxA, a)); } It takes a distance, velocity, maximum acceleration and time delta and returns the acceleration that needs to be applied to reach the destination and stop there given acceleration and velocity constraints. The attractive part of this is that the destination can be changed at will and the formula will always work out. And if the acceleration and velocity constraints are such as to prevent exactly stopping on the target, it will simply overshoot and correct. I've come to this after first trying to apply tweening to my problem. But perhaps this can be wrapped into a custom tween. Basic demo: http://codepen.io/killroy/pen/jyaKYo Real-world demo: http://codepen.io/killroy/pen/MJvGLW I've developed it for various applications in an RTS game (such as turning turrets and ship motion), but I constantly find other applications for it. Cheers!
×