Math / Physics 101 GAM 376 Robin Burke Winter 2008.

Slides:



Advertisements
Similar presentations
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Advertisements

Chapter 2: Describing Motion in 1-D
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
MOMENTUM AND COLLISIONS
Chapter 12: Momentum 12.1 Momentum
Mathematics Algebra 1 Trigonometry Geometry The Meaning of Numbers Choosing the Correct Equation(s) Trig and Geometry Mathematics is a language. It is.
Vectors and Two Dimensional Motion
Chris Hall Aerospace and Ocean Engineering
1Notes  Demetri Terzopoulos talk: Thursday, 4pm Dempster 310.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Physics 106: Mechanics Lecture 01
Physics of Rolling Ball Coasters
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Mathematical Fundamentals
February 21, 2000Robotics 1 Copyright Martin P. Aalund, Ph.D. Computational Considerations.
Game Physics – Part IV Moving to 3D
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Chapter 4.1 Mathematical Concepts
Scalars and Vectors Scalars are quantities that are fully described by a magnitude (or numerical value) alone. Vectors are quantities that are fully described.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Game Physics – Part I Dan Fleck Coming up: Rigid Body Dynamics.
Conservation of Angular Momentum 8.01 W10D2
Chapter 10 Rotation of a Rigid Object about a Fixed Axis.
CSCE 552 Spring 2011 Math By Jijun Tang. Layered.
MA4248 Weeks 1-3. Topics Coordinate Systems, Kinematics, Newton’s Laws, Inertial Mass, Force, Momentum, Energy, Harmonic Oscillations (Springs and Pendulums)
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
Math Review Units, Scientific Notation, Significant Figures, and Dimensional analysis Algebra - –Per Cent Change –Solving simultaneous equations –Cramers.
Mechanics Unit 5: Motion and Forces 5.6 Motion in one Dimension - Speed and Velocity, Acceleration...
Period 1 Pg Ques: 27, 33, 36, 56, 58a, 60-62, 66, 68b.
Questions From Reading Activity? Big Idea(s):  The interactions of an object with other objects can be described by forces.  Interactions between.
Chapter 2 One Dimensional Kinematics
Ch. 2: Describing Motion: Kinematics in One Dimension.
Chapter 2, Kinematics. Terminology Mechanics = Study of objects in motion. –2 parts to mechanics. Kinematics = Description of HOW objects move. –Chapters.
When the axis of rotation is fixed, all particles move in a circle. Because the object is rigid, they move through the same angular displacement in the.
Ch. 2: Describing Motion: Kinematics in One Dimension.
Mechanics 105 Standards Dimensional analysis Unit conversions Order of magnitude calculations/estimation Significant figures Coordinates Vectors and scalars.
Chapter 3 : Motion Weerachai Siripunvaraporn Department of Physics, Faculty of Science Mahidol University &msn :
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Kinematics in Two Dimensions AP Physics 1. Cartesian Coordinates When we describe motion, we commonly use the Cartesian plane in order to identify an.
Chapter 11 Angular Momentum. Angular momentum plays a key role in rotational dynamics. There is a principle of conservation of angular momentum.  In.
Rotational Kinetic Energy An object rotating about some axis with an angular speed, , has rotational kinetic energy even though it may not have.
Biology – Premed Windsor University School of Medicine and Health Sciences Jamaine Rowe Course Instructor.
Describing Motion Physics 11. Cartesian Coordinates When we describe motion, we commonly use the Cartesian plane in order to identify an object’s position.
Wednesday, Feb. 4, 2009PHYS , Spring 2009 Dr. Jaehoon Yu 1 PHYS 1441 – Section 002 Lecture #3 Wednesday, Feb. 4, 2009 Dr. Jaehoon Yu Dimensional.
POSITION AND COORDINATES l to specify a position, need: reference point (“origin”) O, distance from origin direction from origin (to define direction,
Chapter 1. Concepts of Motion
Circular Motion and Other Applications of Newton’s Laws
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Rick Parent - CIS682 Rigid Body Dynamics simulate basic physics of an object subject to forces Keyframing can be tedious - especially to get ‘realism’
Monday, Sept. 20, 2010PHYS , Fall 2010 Dr. Jaehoon Yu 1 PHYS 1441 – Section 002 Lecture #5 Monday, Sept. 20, 2010 Dr. Jaehoon Yu One Dimensional.
1 Do Now: What makes the shuttle go UP? Objectives: Utilize IMPULSE to calculate: Force – time – change in velocity Home work: Page 233: #’s 1 – 5 all.
Monday, June 13, 2011PHYS , Spring 2011 Dr. Jaehoon Yu 1 PHYS 1443 – Section 001 Lecture #5 Monday, June 13, 2011 Dr. Jaehoon Yu Newton’s Laws.
Wednesday, Feb. 4, 2004PHYS , Spring 2004 Dr. Jaehoon Yu 1 PHYS 1441 – Section 004 Lecture #5 Wednesday, Feb. 4, 2004 Dr. Jaehoon Yu Chapter two:
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Learning from the Past, Looking to the Future James R. (Jim) Beaty, PhD - NASA Langley Research Center Vehicle Analysis Branch, Systems Analysis & Concepts.
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
PHYS 1441 – Section 002 Lecture #6
Last Time: One-Dimensional Motion with Constant Acceleration
Vectors & Equilibrium Sara sultan 07/04/2019.
Math review - scalars, vectors, and matrices
Game Programming Algorithms and Techniques
Motion and Momentum S8P3: Students will investigate relationship between force, mass, and the motion of objects.
Presentation transcript:

Math / Physics 101 GAM 376 Robin Burke Winter 2008

Homework #1 Use my code not Buckland’s web site Visual Studio Express see DL’s comments (col site)

Discussion site any course-related topic

Begin math / physics 101 If you’ve taken GAM 350 or any other kind of physics mostly review Vectors Coordinate spaces Kinematics

Why physics? What does physics have to do with AI? Game characters must react to the world and its physics must make predictions about what will happen next must take actions that depend on the world’s physical properties

Why physics? This is the most fundamental form of “avoiding stupidity” Game characters should act as though they understand the physical world of the game will often be blind to other aspects of the game

Vector A multi-dimensional quantity represented by a tuple of numbers We will deal mostly with 2-D vectors 3-D vectors are more mathematically complex but not fundamentally different for AI purposes

Vectors can represent positions is a position 1 unit north and 1 unit east of the origin can also represent velocities is a speed of 5 units in a northwesterly direction other quantities orientation, acceleration, angle, etc.

Vector operations Magnitude v = | v | = magnitude(v) = sqrt(x1 2 +y1 2 ) the length of the vector Adding + = Scalar multiplication * z = changes only the length Normalization v / |v| makes a vector of length 1 does not change the orientation of the vector

More vector operations dot product ● = x1 * x2 + y1 *y2 scalar quantity related to the angle between vectors cos (angle) = u ● v / | u | | v | Note if u and v are normalized (length = 1) then u ● v is the cosine of the angle between them

Example we have two agents: a, b each has a vector position and a normalized vector orientation the direction they are facing turn to face an enemy agent: P a, O a enemy: P b, O b vector from agent to enemy P ba = P b -P a normalize it compute dot product norm(P ba ) ● O a compute inverse cosine this is the angle to turn

Pa Turn to face Pb Pb-Pa cos -1 (Oa norm(Pb-Pa))

What if I want to run away?

Normal vectors A normal vector is orthogonal to another vector in 2 dimensions = 90 degrees n ● v = 0

Coordinate transformations We will always want to move back and forth between coordinate systems objects each have their own local coordinate systems related to each other in "world space" Example NPC a character is at a particular position, facing a particular direction he defines a coordinate system Door the door has its own coordinate system in that system, the handle is in a particular spot To make the character reach for the handle we have to make the two coordinate systems interact

Transformations We know where the handle is in door space where the agent's hand is in agent space what is the vector in agent space Set of transformations transform handle location L 0 to world space L w transform handle location to agent space L a Each transformation is a translation (changing the origin) and a rotation changing the orientation

Affine transformations Usually coordinate transformations are done through matrix multiplications we multiply a vector by a matrix and get another vector out The curious thing is that to do this we have to use vectors and matrices one size larger than our current number of dimensions you will see as the representation of 2-D vector and for 3-D

Matrix math 2-D dimensional array Matrix multiplication F x G dot product of rows of F columns of G corrolary multiplication only works if cols of F = rows of G

Matrix math Can also multiply a vector times a matrix v x M Result a new vector each entry a dot product of v with a different row of M length of v must equal number of cols in M

Example rotation around the origin by angle θ matrix multiply by current vector becomes answer x = cos(θ) – sin (θ) + 0 y = sin(θ) + cos(θ) + 0 z = 1

x' = x cos(θ) – y sin(θ) y' = x sin(θ) + y cos(θ) (1, 2) θ = -π / 4 (2.12, 0.70)

Translation Achieved by adding values at the ends of the top two rows This rotates and translates by (3, -4)

Efficiency Mathematical operations are expensive especially trigonometric ones (inverse cosine) also square root multiplication and division, too Normalization is particularly expensive square root, squaring and division We want to consider ways to make our calculations faster especially if we are doing them a lot

Squared space We can do calculations in "squared space" never have to do square roots Example test whether one vector is longer than another sqrt(X1 2 +Y1 2 ) > sqrt(X2 2 +Y2 2 ) X1 2 +Y1 2 > X2 2 +Y2 2 both will give the same result

Exercise

Kinematics the physics of motion we worry about this a lot in computer games moving through space, collisions, etc. our NPCs have to understand this too in order to avoid stupidity

Basic kinematics position a vector in space (point position) for a large object we use a convenient point classically the center of mass velocity the change of position over time expressed as a vector p t+1 = p t + vΔt if we define the time interval Δt to be 1 we avoid a multiplication

Basic kinematics II Acceleration change in velocity over time also expressed as a vector v t+1 = v t + a Δt Pair of difference equations

Numerical methods We want to run a simulation that shows what happens But now we have a problem there is a lag of 1 time step before acceleration impacts position not physically accurate Example deceleration to stop t = 0, d = 0, v = 10, a = 0 t = 1, d = 10, v = 10, a = -5 t = 2, d = 20, v = 5, a = -5 t = 3, d = 25, v = 0, a = 0 Correct distance traveled Δd = v 0 Δt + ½ a Δt 2 Δd = 10 d = 20

We can improve our simulation finer time step (expensive) improved estimation methods for example instead of using v t, we can use the average of v t and v t+1 Example t=0, d=0, v=10, a =0 t=1, d=10, v=10, a = -5 t=2, d=17.5, v=5, a=-5 t=3, d=20, v=0, a=0 better we slow down in the first time step correct final answer but only works if acceleration is constant take GAM 350 for better ways

Another derivation time velocity v(t) v(t+1)

What does this have to do with AI? Imagine a NPC he has to decide how hard to throw a grenade that judgment has to be based on an estimate of the item’s trajectory When NPC take physical actions we have to know what the parameters of those actions should be very often physics calculations are required not as detailed as the calculations needed to run the game

Approximation in Prediction NPC will frequently need to predict the future where will the player be by the time my rocket gets there? Assumptions current velocity stays constant we know the speed of the rocket Correct way vector algebra lots of square roots and trig functions Typical approximation use the current distance won't change that much if the rocket is fast

Accuracy? Accuracy may be overrated for NPC enemies We want an enjoyable playing experience no warning sniper attack is realistic but no fun a game has to give the player a chance Built-in inaccuracy many games have enemies deliberately miss on the first couple of shots others build random inaccuracy into all calculations others use weak assumptions about physics simplify the calculations and give a degree of inaccuracy

Force Netwon's law F = m*a In other words acceleration is a function of force and mass Force is also a vector quantity a force acting along a vector imparts a velocity along that vector

Example When a bat hits a ball we will want to determine the force imparted to the ball we could simulate this with the mass of the bat and its speed more likely, we would just have a built-in value direction of the force we need to know the angle of the bat when it strikes the ball

More complex motions To handle rotation we also have to worry about torque and angular momentum For example if a rocket hits the back of a car it will spin if it hits the center, it will not

Torque Force applied around the center of mass of an object torque gives rise to angular acceleration (spin) t = d F = I α d = moment arm

For our purposes We will ignore rotational motion deal only with forces acting on points typical simplification for AI

Thursday Finite state machines