Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayamflow/1a9e1ae85157271f0d3c to your computer and use it in GitHub Desktop.
Save ayamflow/1a9e1ae85157271f0d3c to your computer and use it in GitHub Desktop.
Code Physics cheat sheet
Code physics cheat sheet
===
- velocity = variation of position over time
- acceleration = variation of velocity over time
- friction = opposite of velocity. Fast friction: using a scalar instead of using an opposite vector. (i.e. velocity * 0.9)
Velocity with spring & friction (AKA elastic ease)
```
velocity += dx * spring
velocity *= friction
x += velocity
```
Kinematics
```
pin.x = this.x + Math.cos(this.theta) * this.width;
pin.y = this.y + Math.sin(this.theta) * this.width;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment