Limit search to available items
Book Cover
E-book
Author Ramtal, Dev, author.

Title Physics for JavaScript games, animation, and simulations : with HTML5 canvas / Dev Ramtal, Adrian Dobre
Published Berkeley, CA : Apress, 2014
New York, Ny : Distributed to the Book trade worldwide by Springer
©2014
Online access available from:
Safari O'Reilly books online    View Resource Record  

Copies

Description 1 online resource (xxiv, 466 pages) : illustrations
Series The expert's voice in Web development
Expert's voice in Web development.
Contents At a Glance -- Contents -- About the Authors -- About the Technical Reviewer -- Acknowledgments -- Introduction -- Part I : The Basics -- Chapter 1: Introduction to Physics Programming -- Why model real physics? -- Creating realistic animation effects -- Creating realistic games -- Building simulations and models -- Generating art from code -- What is physics? -- Everything behaves according to the laws of physics -- The laws can be written as math equations -- Predicting motion -- Programming physics -- 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 -- Some code at last! -- Summary -- Chapter 2: JavaScript and HTML5 Canvas Basics -- HTML5, the canvas element, and JavaScript -- A minimal HTML5 document -- The canvas element -- Adding JavaScript -- The JavaScript debugging console -- JavaScript objects -- Objects and properties -- Functions and methods -- Prototypes, constructors, and inheritance -- Static properties and methods -- Example: a Ball object -- JavaScript frameworks, libraries, and APIs -- JavaScript language basics -- Variables -- Data types -- Numbers -- Strings -- Booleans -- Undefined and Null -- Objects, Functions, and Arrays -- Operators -- Math -- Logic -- Loops -- Events and user interaction -- Event listeners and handlers -- User interaction: keyboard, mouse, and touch events -- Drag and drop -- The canvas coordinate system -- The canvas drawing API -- The canvas context -- Drawing lines and curves -- Creating fills and gradients -- Animating using the canvas context -- Producing animation using code -- Using JavaScript timers -- Using requestAnimationFrame()
Using getTime() to compute elapsed time -- Precalculating motion -- Summary -- Chapter 3: Some Math Background -- Coordinates and simple graphs -- Building a plotter: the Graph object -- Plotting functions using the Graph object -- Drawing straight lines -- Drawing polynomial curves -- Things that grow and decay: exponential and log functions -- Making an object move along a curve -- Fun with hills -- The trouble with circles -- Using parametric equations -- Finding the distance between two points -- Basic trigonometry -- Degrees and radians -- The sine function -- The cosine function -- The tangent function -- The inverse trig functions -- Using trig functions for animation -- Wavelength, period, frequency and angular frequency -- Oscillations -- Damped oscillations -- Combining sine waves -- Vectors and basic vector algebra -- What are vectors? -- Vectors vs. scalars -- Adding and subtracting vectors -- Resolving vectors: vector components -- Position vectors -- Adding vectors using components -- Multiplying a vector by a number -- Vector magnitude -- Vector angle -- Multiplying vectors: Scalar or dot product -- Multiplying vectors: Vector or cross product -- Building a Vector object with vector algebra -- Simple calculus ideas -- Slope of a line: gradient -- Rates of change: derivatives -- Discrete calculus: difference equations -- Doing sums: integrals -- Summary -- Chapter 4: Basic Physics Concepts -- General physics concepts and notation -- Physical quantities and units -- Scientific notation -- Things: particles and other objects in physics -- What is a particle? -- Particle properties -- Building a Particle object -- Extending the Particle object -- The Ball object -- Using the Ball object -- Moving particles -- Describing motion: kinematics -- Concepts: displacement, velocity, speed, acceleration -- Displacement -- Velocity -- Speed
Acceleration -- Combining vector quantities -- 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 cause of motion: forces -- The relationship between force, mass, and acceleration -- Types of forces -- Combining forces: force diagrams and resultant force -- Forces in equilibrium -- Example: Object falling under gravity and drag -- Energy concepts -- The notion of work in physics -- The capacity to do work: energy -- Energy transfer, conversion, and conservation -- Potential and kinetic energy -- Power -- Example: A rudimentary "car" simulation -- Summary -- Part II : Particles, Forces, and Motion -- Chapter 5: The Laws Governing Motion -- Newton's laws of motion -- Newton's first law of motion (N1) -- Newton's second law of motion (N2) -- Newton's third law of motion (N3) -- Applying Newton's laws -- General method for applying F = m a -- Coding up motion under any force -- The Forces object -- 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 = m a -- 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 -- Summary -- Chapter 6: Gravity, Orbits, and Rockets -- Gravity -- Gravity, weight, and mass -- Newton's universal law of gravitation -- Creating the gravity function -- Orbits -- The orbits code -- Escape velocity -- Two-body motion -- Local gravity -- The force of gravity near the Earth's surface
Variation of gravity with height -- Gravity on other celestial bodies -- Rockets -- It is rocket science! -- Modeling the thrust of a rocket -- Building a rocket simulation -- The Rocket object -- Summary -- Chapter 7: Contact and Fluid Forces -- Contact forces -- Normal contact forces -- Tension and compression -- Friction -- Modeling static and kinetic friction -- Coefficients of friction -- Example: Sliding down a slope -- The physics -- Creating the visual setup -- Coding the animation -- Pressure -- The meaning of pressure -- Density -- Variation of pressure with depth in a fluid -- Static and dynamic pressure -- Upthrust (buoyancy) -- Archimedes' Principle -- Apparent weight -- Submerged objects -- Floating objects -- Example: Balloon -- Drag -- Drag law for low velocities -- Drag law for high velocities -- Which drag law should I use? -- Adding drag to the balloon simulation -- Example: Floating ball -- Terminal velocity -- Example: Parachute -- Lift -- Lift coefficients -- Example: An airplane -- Wind and turbulence -- Force due to the wind -- Wind and drag -- Steady and turbulent flow -- Example: Air bubbles in a steady wind -- Modeling turbulence -- Summary -- Chapter 8: Restoring Forces: Springs and Oscillations -- Springs and oscillations: Basic concepts -- Spring-like motion -- Restoring force, damping, and forcing -- Hooke's law -- Free oscillations -- The spring force function -- Creating a basic oscillator -- Simple harmonic motion -- Oscillations and numerical accuracy -- Damped oscillations -- Damping force -- The effect of damping on oscillations -- Analytical solutions for oscillations with damping -- Forced oscillations -- Driving forces -- 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 -- Summary -- Chapter 9: Centripetal Forces: Rotational Motion -- Kinematics of uniform circular motion -- Angular displacement -- Angular velocity -- Angular acceleration -- Period, frequency, and angular velocity -- The relationship between angular velocity and linear velocity -- Example: A rolling wheel -- Example: Satellite around a rotating Earth -- Centripetal acceleration and centripetal force -- Centripetal acceleration -- Centripetal acceleration, velocity, and angular velocity -- Centripetal force -- Common misconceptions about centripetal force -- Example: Revisiting the satellite animation -- Example: Circular orbits with gravitational force -- Example: Car moving around a bend -- Non-uniform circular motion -- Tangential force and acceleration -- Example: A simple pendulum -- Summary -- Chapter 10: Long-Range Forces -- Particle interactions and force fields -- Interaction at a distance -- From particle interactions to force fields -- Newtonian gravitation -- 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 -- Creating the visual setup -- Programming the game functionality -- Electrostatic force -- Electric charge -- Coulomb's law of electrostatics -- Charged particle attraction and repulsion -- Electric fields -- Electric field due to a charged particle -- Time-varying electric fields -- Electromagnetic force -- Magnetic fields and forces -- The Lorentz force law -- Other force laws -- Central forces -- Gravity with a spring force law? -- Multiple attractors with different laws of gravity -- Summary -- Part III : Multi-particle and Extended Systems -- Chapter 11: Collisions
Summary "Have you ever wanted to include believable physical behaviors in your games and projects to give them that extra edge? Physics for JavaScript Games, Animation, and Simulations teaches you how to incorporate real physics, such as gravity, friction, and buoyancy, into your HTML5 games, animations, and simulations. It also includes more advanced topics, such as particle systems, which are essential for creating effects such as sparks or smoke. The book also addresses the key issue of balancing accuracy and simplicity in your games and simulations, and the final chapters provide you with the information and the code to make the right choice for your project. Physics for JavaScript Games, Animation, and Simulations assumes you have a basic knowledge of JavaScript and HTML5. However, no previous knowledge of physics is required - only some very basic math skills. The authors present everything from basic principles to advanced concepts in an approachable way, so you'll be able to follow the logic and easily adapt the principles to your own applications. The book is packed full of practical examples of how you can apply physics to your own games and applications. Spring behaviors can be used for anything from tweaking lowrider suspension to creating cloth simulation; flotation mechanics enable the simulation of submersibles or dirigibles; you can even create your own solar system with accurate orbits and gravity. It doesn't matter if you're modeling the Lorentz force in an electromagnetic field or you're modeling the lift force in a flight simulator, Physics for JavaScript Games, Animation, and Simulations enables you to fill your games and applications with accurate and realistic effects. What you'll learn: Learn all the basic math and physics you'll need to incorporate realism into your projects; Incorporate a wide range of forces, such as gravity, friction, and buoyancy; Build a number of realistic simulations; Model particle systems and use them to create visual effects; Create complex systems using rigid bodies and mass-spring systems; Deal with numerical subtleties, including accuracy and stability of integration schemes. This book is for JavaScript developers interested in incorporating real physics into their games, animations, simulations, or generative art projects."-- Unedited summary from book
Analysis computerwetenschappen
computer sciences
Information and Communication Technology (General)
Informatie- en communicatietechnologie (algemeen)
Notes Includes index
Online resource; title from PDF title page (SpringerLink, viewed June 20, 2014)
Subject Physics -- Computer simulations
Computer games -- Programming.
JavaScript (Computer program language)
HTML (Document markup language)
SCIENCE -- Energy.
SCIENCE -- Mechanics -- General.
SCIENCE -- Physics -- General.
Computer games -- Programming.
HTML (Document markup language)
JavaScript (Computer program language)
Form Electronic book
Author Dobre, Adrian, 1971- author.
ISBN 9781430263388
1430263385