Angular velocity and angular acceleration
The rotational analogue of the position/velocity/acceleration chain: accumulate angular acceleration into angular velocity, then angular velocity into angle, every frame.
What it is
Two running totals: an angular acceleration value adds into an angular velocity value, and that velocity adds into an angle. Nature of Code defines angular velocity as “the rate at which an object’s angle changes over time” and presents the two-line update as the “Standard angular motion algorithm.”
How it works
The two lines run in this order:
angleVelocity += angleAcceleration;angle += angleVelocity;
Velocity adds in acceleration first; angle adds in the updated velocity
second. Nothing else is stated about how angleAcceleration itself gets set
— the algorithm as given only covers what happens to it once it exists.
Parameters & tuning
angleAcceleration is the amount added into angleVelocity on each pass
through these two lines: raise it and the object spins faster with every
pass, because velocity itself keeps climbing instead of holding steady.
angleVelocity is the amount added into angle on each pass: raise it
directly and rotation speed changes immediately, without the ramp-up
acceleration produces.
One reading of these two lines alone, not stated in the source: a nonzero
angleAcceleration left running has nothing here to stop angleVelocity
climbing indefinitely, so a sketch built from just this pair eventually spins
fast enough between passes to read as flicker rather than smooth rotation.
Where it’s been used
Nature of Code names this the “Standard angular motion algorithm.” This bundle doesn’t tie it to a named artwork or artist beyond that framing.
Variants & neighbours
Simple harmonic motion gets a comparable back-and-forth motion a different way entirely: instead of adding acceleration into velocity and velocity into angle in turn, it maps an ever-increasing angle straight through sin() or cos(), scaled by an amplitude, for a controllable period — no acceleration term at all.
Pendulum motion is one thing this loop gets used to build: it layers a torque-driven angular restoring force — gravity times the sine of the swing angle, divided by arm length — on top of the same angle/angleVelocity/angleAcceleration bookkeeping, producing a swing independent of the bob’s mass.
Go deeper
- The Nature of Code — the definition and the two update lines this page follows.
Connected to
Contrast with: Simple harmonic motion
Used to build: Pendulum motion
Kinds of this: Simple harmonic motion