Animation
See also Physics
https://github.com/MengTo/Spring/blob/master/Spring/Spring.swift
Resources
The illusion of life
![The illusion of life_hd.mp4](The illusion of life_hd.mp4) ![10 principles of motion design.mp4](10 principles of motion design.mp4)
Precision
Eular method is frame based More precise is time based
The Eular method simplifies equation:
The semi-implicit euler (better):
frame skip = based on time non frame skip = based on number frames. It's not precise especially if the frame rate is irregular or not at the original speed
Recusive functions are frame based
Eular method:
See also:
Time based (use integration and calculus):
Physics for Flash Games - difference between integrator
PhysicsJS/src/integrators at master · wellcaffeinated/PhysicsJS - Implementation of different integrators in PhysicsJS
Eular method
Inching
Aka Ease out animation
position += (destination - position) * friction
Elastic
Simple harmonic motion — Wikipedia
Flexible Partial Shifts
Waveform
Heartthrob
Easing
See also Catmull–Rom spline and Gradient
https://github.com/greensock/GreenSock-JS/blob/master/src/uncompressed/easing/EasePack.js
Inigo Quilez :: fractals, computer graphics, mathematics, demoscene and more - useful little functions
Better Cubic Bezier Approximations for Robert Penner Easing Equations | kepo-ing Zz85 - see https://github.com/zz85/cubic-bezier-approximations
curves | kynd.info | Flickr - Easing functions/equations https://farm8.staticflickr.com/7346/9546075099_18ccc66a2d_o_d.png
sin(t)
cos(t)
cos(t)*sin(t)
sin(t)*sin(t*1.5)
sin(tan(cos(t)*1.2))
sin(tan(t)*0.05)
cos(sin(t*3))*sin(t*0.2)
sin(pow(8,sin(t)))
sin(exp(cos(t*0.8))*2)
sin(t-PI*tan(t)*0.01)
pow(sin(t*PI),12)
cos(sin(t)*tan(t*PI)*PI/8)
sin(tan(t)*pow(sin(t),10))
cos(sin(t*3)+t*3)
pow(abs(sin(t*2))*0.6,sin(t*2))*0.6
... (see links above)
cos(pi*x) / (-LN2*x)
sqrt(1-x^2)
Semi arc (* -1 to get negative)1-pow(x*2-1, 6)
smooth in-out, use power of 2, 4, 6, etc. to make the transition sharperLinear (Power0)
Quad (Power1)
Cubic (Power2)
Quart (Power3)
Quint (Power4)
Strong (Power4)
Time progression
Animation duration
Physics based
Animation based on physics
Use friction, attraction force (gravity, magnetism), push force Mass, velocity (speed + direction), momentum
See Physics
Lib for lot of domains (math, graphics) https://github.com/hapticdata/toxiclibsjs from http://toxiclibs.org/about/
https://en.wikipedia.org/wiki/Physics_engine
A posteriori (discrete) versus a priori (continuous) computation: https://en.wikipedia.org/wiki/Collision_detection#A_posteriori_.28discrete.29_versus_a_priori_.28continuous.29
https://openclassrooms.com/courses/theorie-des-collisions
Parametric easing (easing function with parameters like frequency, friction) http://dynamicsjs.com
game libs http://phaser.io https://libgdx.badlogicgames.com/index.html
native JS canvas only lib https://github.com/phoboslab/Ejecta
https://en.wikipedia.org/wiki/Force https://en.wikipedia.org/wiki/Classical_mechanics
Cat walking
Cats have a very precise method of walking, called “direct registering”, wherein their hind paws fall almost exactly into the place their fore paws did a moment before—this method of walking minimizes noise and visible tracks while ensuring more stable footing as the place has already been felt out by the fore paws
Draggable with inertia
Scrollable, deceleration, rubber band, paging (aka Soft close drawer)
Linear Motion Equations:
vf = vi + at d = ½(vf + vi)t d = vi∙t + ½at vf² = vi² + 2ad
where:
d is displacement (∆x)
t is time of travel (∆t)
a is rate of constant acceleration
vi is initial velocity
vf is final velocity
https://s2.studylib.net/store/data/005704450.pdf?key=7f28457ce04d3cb302b11a2f52dba5b3&r=1&fn=5704450.pdf&t=1536095317883&p=600
Rubber-banding: x = (1.0 - (1.0 / ((x * c / d) + 1.0))) * d or x = x * 0.5
f(x, d, c) = (x * d * c) / (d + c * x)
where:
x is distance from the edge
c is constant (UIScrollView uses 0.55)
d is dimension, either width or height
UIScrollView to find out the formulae its using for paging, inertia, and bouncing: rubber banding: offset = (0.55 * offset * height) / (height + 0.55 * offset); inertia: exponential decay with .decelerationRate
Implementing scrolling behaviour without UIScrollView – Successful coder - (end of article) about need to evaluate multiple touchmove events at the end of gesture to get the velocity desizered
Scrolling — Wikipedia - "Touch-screens often use inertial scrolling"
kinetic scrolling: the state machine · ariya.io - State machine for a slider
Creating Animations and Interactions with Physical Models https://github.com/iamralpht/iamralpht.github.io/tree/master/physics
Draggable | GSAP from GreenSock | JavaScript HTML5 Animation https://github.com/kevinglb/Cartier-Wechat/blob/master/greensock-js/src/uncompressed/utils/Draggable.js https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/ThrowPropsPlugin.min.js https://github.com/iWoz/AirScroll/blob/master/src/com/greensock/plugins/ThrowPropsPlugin.as
Add experimental support for spring based CSS animations - see
WebCore/platform/graphics/SpringSolver.h
Like scroll with touch or mouse wheel. See also http://dev.w3.org/csswg/css-snappoints/, -ms-scroll-limit
(offlimit bounce) and https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/IpBdJEppjzE/V1Biy1D4v-kJ
Scroll time based on distance:
Friction:
vector velocity = speed + direction
google maps Speed decrease like POWER2
f(x) = 99.9%^x
drop (a=0→1)
v = d / t where v = speed or velocity d = distance t = time or duration
stopping distance: start velocity to 0 d = k * v * v, where d = distance k = friction coef v = start speed or velocity
stopping duration?ranl(fr) t = d / v t = time or duration v = average speed or velocity (= start speed / 2) d = distance
In source of the map engine Leaflet https://github.com/Leaflet/Leaflet/blob/63fd4edc76893ab2a2f83d54e703e0a4da73de7b/src/map/handler/Map.Drag.js
Particles
Character control
Last updated