Contents
Chapter 1: Introduction to Physics Programming
Creating realistic animation effects
Building simulations and models
Everything behaves according to the laws of physics
The laws can be written as math equations
The difference between animation and simulation
The laws of physics are simple equations
Equations can be readily coded up!
The four steps for programming physics
A simple physics simulation example
The physics of a bouncing ball
Coding up a bouncing ball in 2D
Chapter 2: JavaScript and HTML5 Canvas Basics
HTML5, the canvas element, and JavaScript
The JavaScript debugging console
Prototypes, constructors, and inheritance
JavaScript frameworks, libraries, and APIs
User interaction: keyboard, mouse, and touch events
Animating using the canvas context
Producing animation using code
Using getTime() to compute elapsed time
Chapter 3: Some Math Background
Building a plotter: the Graph object
Plotting functions using the Graph object
Things that grow and decay: exponential and log functions
Making an object move along a curve
Finding the distance between two points
Using trig functions for animation
Vectors and basic vector algebra
Adding and subtracting vectors
Resolving vectors: vector components
Multiplying vectors: Scalar or dot product
Multiplying vectors: Vector or cross product
Building a Vector object with vector algebra
Chapter 4: Basic Physics Concepts
General physics concepts and notation
Things: particles and other objects in physics
Concepts: displacement, velocity, speed, acceleration
Describing motion using graphs
Equations of motion for uniform acceleration
Example: Applying the equations to projectile motion
More motion-related concepts: inertia, mass, and momentum
Predicting motion: forces and dynamics
The relationship between force, mass, and acceleration
Combining forces: force diagrams and resultant force
Example: Object falling under gravity and drag
The capacity to do work: energy
Energy transfer, conversion, and conservation
Example: A rudimentary “car” simulation
Part II: Particles, Forces, and Motion
Chapter 5: The Laws Governing Motion
Newton’s first law of motion (N1)
Newton’s second law of motion (N2)
Newton’s third law of motion (N3)
General method for applying F = ma
Coding up motion under any force
A simple example: projectile with drag
A more complicated example: floating ball
Newton’s second law as a differential equation
Taking a deeper look at F = ma
Example: Falling under gravity and drag revisited
The principle of energy conservation
Conservation of mechanical energy
Example: Energy changes in a projectile
The principle of momentum conservation
Example: 1D elastic collision between two particles
Laws governing rotational motion
Chapter 6: Gravity, Orbits, and Rockets
Newton’s universal law of gravitation
The force of gravity near the Earth’s surface
Variation of gravity with height
Gravity on other celestial bodies
Modeling the thrust of a rocket
Chapter 7: Contact and Fluid Forces
Variation of pressure with depth in a fluid
Adding drag to the balloon simulation
Example: Air bubbles in a steady wind
Chapter 8: Restoring Forces: Springs and Oscillations
Springs and oscillations: Basic concepts
Restoring force, damping, and forcing
Oscillations and numerical accuracy
The effect of damping on oscillations
Analytical solutions for oscillations with damping
Example: A periodic driving force
Example: A random driving force
Gravity as a driving force: bungee jumping
Example: Driving force by user interaction
Coupled oscillators: Multiple springs and objects
Example: A chain of objects connected by springs
Chapter 9: Centripetal Forces: Rotational Motion
Kinematics of uniform circular motion
Period, frequency, and angular velocity
The relationship between angular velocity and linear velocity
Example: Satellite around a rotating Earth
Centripetal acceleration and centripetal force
Centripetal acceleration, velocity, and angular velocity
Common misconceptions about centripetal force
Example: Revisiting the satellite animation
Example: Circular orbits with gravitational force
Example: Car moving around a bend
Tangential force and acceleration
Particle interactions and force fields
From particle interactions to force fields
Gravitational field due to a particle
Gravity with multiple orbiters
Gravity with multiple attractors
Particle trajectories in a gravity field
Building a simple black hole game
Coulomb’s law of electrostatics
Charged particle attraction and repulsion
Gravity with a spring force law?
Multiple attractors with different laws of gravity
Part III: Multi-particle and Extended Systems
Bouncing off horizontal or vertical walls
Collision detection with an inclined wall
Velocity correction just before collision
Example: a ball bouncing off an inclined wall
Example: Ball bouncing off multiple inclined walls
Collisions between particles in 1D
Collisions between particles in 2D
Example: 2D collisions between two particles
Example: multiple particle collisions
Example: multiple particle collisions with bouncing
Introduction to particle system modeling
Creating animated effects using particles
A simple example: splash effect with particles
Particle animations with long-range forces
Particle paths in a force field
Multiple particles under mutual gravity
Basic concepts of rigid body modeling
Rotational dynamics of rigid bodies
Simulating rigid body dynamics
Example: a simple wind turbine simulation
Example: Rolling down an inclined plane
Rigid body collisions and bouncing
Example: Simulating a single bouncing block
Part IV: Building More Complex Simulations
Chapter 14: Numerical Integration Schemes, Accuracy, and Scaling
Characteristics of numerical schemes
A simple example to demonstrate different integration schemes
Comparing the explicit and semi-implicit Euler schemes
Second-order Runge-Kutta scheme (RK2)
Fourth-order Runge-Kutta scheme (RK4)
Stability and accuracy of RK2 and RK4 compared with Euler
Testing the stability and accuracy of the Verlet schemes
Choosing an appropriate integration scheme
Using accurate initial conditions
Dealing with boundaries carefully
Scaling factors and parameter values
Chapter 15: Doing Physics in 3D
3D rendering: Introducing WebGL and three.js
Canvas, WebGL, and WebGL frameworks
Simulating particle motion in 3D
A bouncing ball simulation in 3D
Forces: gravity and orbits in 3D
Simulating rigid body motion in 3D
Applying a force to the rotating cube
Rotating the cube about an arbitrary axis
Chapter 16: Simulation Projects
Adding controls and visual effects
Physics and control mechanisms of aircraft
Creating an accurate solar system model
Coding up an appropriate integration scheme
Building an idealized single-planet simulation
Choosing appropriate scaling factors
Obtaining planetary data and initial conditions
Creating a basic solar system model
Incorporating accurate initial conditions
Comparing the model results with NASA data
18.119.136.84