Velocity
Velocity is a quantity or state representing movement or change through a space, often encoding its direction and magnitude.
Math for Web Design
Velocity is the rate of change of an object's position together with its direction of motion.
- How it is used
- Drives JavaScript and canvas animations by converting elapsed time into directional position changes.
- How deep it goes
- Explains time-based position updates, acceleration layering, collisions, springs, friction, and component velocities through runnable animation patterns.
- Examples
- Demonstrates a sliding notification, accelerated motion, draggable inertia, balloon particles, star fields, and falling confetti.
- What you can do after
- Build it from scratch in JavaScript by updating positions from velocity and elapsed time, then modifying velocity with simulated forces.
Optimization Algorithms: AI techniques for design, planning, and control problems
A sequence of swaps that specifies how a particle's permutation is transformed in permutation-based particle swarm optimization.
- How it is used
- Represents the swaps that move a particle between candidate routes in permutation-based particle swarm optimization.
- How deep it goes
- Defines velocity through swaps and explains redefined multiplication, subtraction, and addition with route illustrations.
- Examples
- Uses an eight-city traveling salesman route and figures showing velocity scaling, position subtraction, and swap application.
- What you can do after
- Apply it via swap operations to transform a route permutation into another candidate solution.
Grokking AI Algorithms, Second Edition
A velocity is a particle's vector describing the direction and magnitude of its movement through the search space.
- How it is used
- Guides particle movement during particle swarm optimization’s repeated search for better solutions.
- How deep it goes
- Explains velocity through inertia, cognitive, and social components, then traces its use in position updates and Python code.
- Examples
- Uses random starting kicks, particle tables, fireflies, plotted movement, and a worked transition from velocity 1.52 to position (0.52, 10.52).
- What you can do after
- Apply via Python by calculating component influences, combining them into velocity, and updating each particle’s position.
Read how Grokking AI Algorithms, Second Edition explains velocity →
Classic Game Programming on the NES: Make your own retro video game
Velocity is a signed positional change applied along a spatial axis to determine an object's movement.
- How it is used
- Moves a bouncing NES ball by applying separate horizontal and vertical values to its sprite coordinates.
- How deep it goes
- Explains initialization, per-loop position updates, and edge-triggered direction changes in assembly.
- Examples
- Uses a ball sprite initialized with unit X and Y velocities and reversed at the visible screen edges.
- What you can do after
- Build it from scratch by storing velocity values, adding them to sprite coordinates, and reversing them at boundaries.
Read how Classic Game Programming on the NES: Make your own retro video game explains velocity →
Related concepts
- particle swarm optimizationused by · Particle swarm optimization is a population-based optimization method in which candidate solutions adjust their positions using individual and collective search information.
- gravityconfigured by · Gravity is the attractive interaction between masses that accelerates objects toward one another.
- accelerationproduced by · Acceleration is the rate at which an object's velocity changes over time.
- velocity clampingconfigured by · Velocity clamping is a particle-swarm constraint that limits each particle’s velocity to a specified minimum and maximum.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



