UFCEKU-20-3Web Games Programming Game Math. UFCEKU-20-3Web Games Programming Agenda Revise some basic concepts Apply Concepts to Game Elements.

Slides:



Advertisements
Similar presentations
D. Trigonometry Math 10: Foundations and Pre-Calculus FP10.4 Develop and apply the primary trigonometric ratios (sine, cosine, tangent) to solve problems.
Advertisements

Sine, Cosine, Tangent, The Height Problem. In Trigonometry, we have some basic trigonometric functions that we will use throughout the course and explore.
Section 10.1 Tangent Ratios.
How did you use math (Geometry) during your spring break?
1 7.2 Right Triangle Trigonometry In this section, we will study the following topics: Evaluating trig functions of acute angles using right triangles.
Trigonometry Review of Pythagorean Theorem Sine, Cosine, & Tangent Functions Laws of Cosines & Sines.
Honors Geometry Section 10.3 Trigonometry on the Unit Circle
17-1 Trigonometric Functions in Triangles
Terminal Arm Length and Special Case Triangles DAY 2.
Finding Exact Values For Trigonometry Functions (Then Using those Values to Evaluate Trigonometry functions and Solve Trigonometry Equations)
4.1: Radian and Degree Measure Objectives: To use radian measure of an angle To convert angle measures back and forth between radians and degrees To find.
© T Madas. Add zero and negative integers Add fractions and decimals which can be represented by fractions Add imaginary numbers Real Numbers ( ) Integers.
6.1Right-Triangle Trigonometry Objectives: 1. Define the six trigonometric ratios of an acute angle in terms of a right triangle. 2. Evaluate trigonometric.
Trigonometry SOH CAH TOA.
Trigonometric Functions
Mathematics By: Andrew Reed-Stum. Equations Definition Equations- An expression or a proposition often algebraic, asserting the quantities.
Copyright  2011 Pearson Canada Inc. Trigonometry T - 1.
Trigonometry. Basic Ratios Find the missing Law of Sines Law of Cosines Special right triangles
Trigonometric Functions Unit Circle Approach. The Unit Circle Definition.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 8 "The games of a people reveal.
Section 13.6a The Unit Circle.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 8 "The games of a.
8-3: Trigonometry Objectives To use the sine, cosine, and tangent ratios to determine side lengths and angle measures in right triangles To use the sine,
MATH 31 LESSONS Chapters 6 & 7: Trigonometry
TRIGONOMETRIC RATIOS Chapter 9.5. New Vocabulary  Trigonometric Ratio: The ratio of the lengths of two sides or a right triangle.  The three basic trigonometric.
Right Triangle Trigonometry
Math Vocabulary By: Keydron Stuckey May 19, st Period Mrs. Bishop.
Chapter 8.3: Trigonometric Ratios. Introduction Trigonometry is a huge branch of Mathematics. In Geometry, we touch on a small portion. Called the “Trigonometric.
4.3 Trigonometry Extended: The Circular Functions
7.5 – 7.6 Trigonometry.
Unit 1-Number Sets Aa-1.1 Define and identify integers, rational, irrational, natural, whole and real numbers.
8.4 Trigonometric Ratios.
Geometry Trigonometry. Learning Outcomes I will be able to set up all trigonometric ratios for a right triangle. I will be able to set up all trigonometric.
Warm- up What do you remember about right triangles?
Trigonometry Section 4.3 Right Triangle Trigonometry.
Trigonometry Revision Booklet Introduction to Trigonometry
Special Right Triangles Definition and use. The Triangle Definition  There are many right angle triangles. Today we are most interested in right.
The Trigonometric Functions SINE COSINE TANGENT. SINE Pronounced “sign”
Ratios for Right Angle Triangles.  Sine = opposite hypotenuse  Cosine = opposite hypotenuse  Tangent = opposite adjacent Sin = OCos = ATan = O H H.
Trigonometry What is trigonometry? Trigonometry (from the Greek trigonon = three angles and metro = measure [1]) is a branch of mathematics dealing with.
7.1 Geometric Mean 7.2 Pythagorean Theorem 7.3 Special Right Triangles 7.4 Trigonometry 7.5 Angles of Elevation & Depression 7.6 Law of Sines 7.7 Law of.
5.1 The Unit Circle.
TRIG – THE EASY WAY.
Lesson: Introduction to Trigonometry - Sine, Cosine, & Tangent
How can you apply right triangle facts to solve real life problems?
Tangent Ratio.
TRIGONOMETRY.
Right Triangle Trigonometry
Rotational Trigonometry: Trig at a Point
Splash Screen.
Trigonometric Functions
Standards MGSE9-12.G.SRT.6 Understand that by similarity, side ratios in right triangles are properties of the angles in the triangle, leading to definitions.
South Central ACT Strategies and Solutions Seminar
Objectives Find the sine, cosine, and tangent of an acute angle.
Arc Length and Radians DO NOW 3/23:
7.4 - The Primary Trigonometric Ratios
Right Triangle Trigonometry
Splash Screen.
The Trigonometric Ratios
5.1 The Unit Circle.
Lesson 4.4 Trigonometric Functions of Any Angle
Basic Trigonometry.
CO1301: Games Concepts Lecture 13 Basic Trigonometry
LESSON ____ SECTION 4.2 The Unit Circle.
Rotational Trigonometry: Trig at a Point
7-5 and 7-6: Apply Trigonometric Ratios
Geometry 9.5 Trigonometric Ratios
Warm-up.
Trigonometric Ratios Geometry.
Maths Unit 23 – Pythagoras & Trigonometry
Presentation transcript:

UFCEKU-20-3Web Games Programming Game Math

UFCEKU-20-3Web Games Programming Agenda Revise some basic concepts Apply Concepts to Game Elements

UFCEKU-20-3Web Games Programming The Natural Numbers The Natural Numbers 1..infinity

UFCEKU-20-3Web Games Programming The Integers The integers = whole numbers positive, negative or zero Computer data type int, uint (AS3) name depends on language in use

UFCEKU-20-3Web Games Programming Rational Numbers The Rationals = fractions with an exact decimal value e.g 1/2 =.5 positive or negative Computer data type long, double,float, real, Number (AS3) name depends on language in use

UFCEKU-20-3Web Games Programming Irrational Numbers The irrationals = fractions without an exact decimal value e.g 1/3 = positive or negative Computer data type as for rationals long, double,float, real, Number

UFCEKU-20-3Web Games Programming The Number Line: Root Square root of

UFCEKU-20-3Web Games Programming The Golden Ratio - Phi The Golden Ratio

UFCEKU-20-3Web Games Programming The Natural Logarithmic Constant e e = …

UFCEKU-20-3Web Games Programming The Number Line PI the Relationship between the diameter of a circle and its circumference (easy) (calculator) valueForPI = Math.PI; // AS3 ( ) Hmm… pie

UFCEKU-20-3Web Games Programming The Number Line Attributes of a Circle: Radius Diameter Circumference Area Radius =r Diameter =2r Circumference = C = PI x D Area = PI x r x r

UFCEKU-20-3Web Games Programming ActionScript const PI:Number = Math.PI;// define a constant public function areaOfCircle(radius:Number):Number { var area:Number; area = PI * radius * radius; return area; }

UFCEKU-20-3Web Games Programming Radians Radian is a natural measurement of angular rotation There are 2PI radians in a circle (~= 6.284)

UFCEKU-20-3Web Games Programming Radians v Degrees There are 2 PI radians in a circle = x 2 = There 360 degrees in a circle One radian = 360 / approximately degrees Formula for changing radians to degrees : degrees = (360 / 2PI) Formula for changing degrees to radians : radians = degrees x (2PI / 360)

UFCEKU-20-3Web Games Programming Pythagoras a b c a 2 = b 2 + c 2

UFCEKU-20-3Web Games Programming Pythagoras a2a2 b2b2 c2c2

UFCEKU-20-3Web Games Programming Pythagoras a = 5 c = 3 b = 4

UFCEKU-20-3Web Games Programming Pythagoras a 2 = a = a = SQRT (25) a = 5

UFCEKU-20-3Web Games Programming Application to Games x y P1 (x1, y1) P2 (x2, y2) Length = x2 - x1 Length = y2 - y1

UFCEKU-20-3Web Games Programming Application to Games x y P1 (10, 15) P2 (80,50 ) Length = x2 - x1 = = 70 Length = y2 - y1 = = 35 a

UFCEKU-20-3Web Games Programming Application to Games x y a distance a = SQRT((x2-x1) 2 + (y2 - y1) 2 )

UFCEKU-20-3Web Games Programming ActionScript // distanceXY calculates the distance between two points x and y // and returns the resulting value public function distanceXY(pointX1, pointY1, pointX2, pointY2:int):Number{ var distance:Number; distance = Math.sqrt((pointX2-pointX1) * (pointX2-pointX1) + (pointY2-pointY1) * (pointY2-pointY1)); return distance }

UFCEKU-20-3Web Games Programming Trigonometry 1 1 cosine sInesIne Tan

UFCEKU-20-3Web Games Programming Sine Values 1 1 cosine sInesIne Rotate line through some angle Read value off sine axis

UFCEKU-20-3Web Games Programming 33 degrees Sine read sine value angle about 0.52

UFCEKU-20-3Web Games Programming Cosine Values 1 1 cosine sInesIne angle 45 degrees

UFCEKU-20-3Web Games Programming Tan Values 1 1 tan Rotate line through some angle (45) Read value off tan axis tan tan(45) = 1

UFCEKU-20-3Web Games Programming Tan Values 1 1 cosine sInesIne Rotate line through some angle (65 degrees) Read value off tan axis (about 2.7)

UFCEKU-20-3Web Games Programming Tan Values 1 1 cosine sInesIne Rotate line through some angle (89 degrees) Read value off tan axis (about )

UFCEKU-20-3Web Games Programming Tan 90 ! 1 1 cosine sInesIne Rotate line through some angle (90 degrees) Lines parallel - tan 90 not defined

UFCEKU-20-3Web Games Programming Tan > cosine sInesIne Rotate line through some angle (135 degrees) value read from this axis (-1)

UFCEKU-20-3Web Games Programming Trigonometric Ratios sine of the angle = opposite / hypotenuse cosine of the angle = adjacent / hypotenuse tan of the angle = opposite / adjacent hypotenuse adjacent Angle in degrees = 1/sine etc. opposite

UFCEKU-20-3Web Games Programming Trig Ratios sine of the angle = opposite / hypotenuse cosine of the angle = adjacent / hypotenuse tan of the angle = opposite / adjacent SOH CAH TOA

UFCEKU-20-3Web Games Programming Finding the angle to a point point(x1,y1) Point (x2, y2) angle theta?

UFCEKU-20-3Web Games Programming Finding the angle to a point point(x1,y1) Point (x2, y2)

UFCEKU-20-3Web Games Programming Finding the angle to a point point(x1,y1) Point (x2, y2) angle theta?

UFCEKU-20-3Web Games Programming Use the tangent formula point(x1,y1) point (x2, y2) angle theta tan theta = opposite / adjacent tan theta= (y2-y1) / (x2-x1) the angle = 1/tan (theta) atan(theta)

UFCEKU-20-3Web Games Programming Calculate for each frame point(x1,y1) point (x2, y2) (moving sprite) angle theta?

UFCEKU-20-3Web Games Programming Some tan angles point to the same value… 1 1 cosine sInesIne tan 225 =1 tan 45 =1

UFCEKU-20-3Web Games Programming Using the atan2 function arctan(x) function may return same angle value for two different points if in certain quadrants - would need to determine which is correct for direction required Use atan2(y,x) specially designed function, which by using numbers in the complex plane, returns one unique value for any angle Value is returned in radians - convert to degrees with appropriate formula

UFCEKU-20-3Web Games Programming ActionScript // definition in GameMath.as public function pointAtSprite(xPoint:Number, yPoint:Number, pointerX:Number, pointerY:Number):Number { var dx:Number = xPoint - pointerX; var dy:Number = yPoint - pointerY; // determine angle and convert to degrees var pointAngle:Number = Math.atan2(dy,dx); var pointDegrees:Number = 360*(pointAngle/(2*Math.PI)); return pointDegrees; } //pointAtSprite stage.addEventListener(Event.ENTER_FRAME, getPointAngle); function getPointAngle(event:Event){ pointAtSpriteAngle= gameMath.pointAtSprite(boat_mc.x, boat_mc.y, pointer.x, pointer.y); pointer.rotation = pointAtSpriteAngle;// instance name of gun turret sprite };

UFCEKU-20-3Web Games Programming Game Math:Applications Used to calculate sprite positions and directions Determine distances between game objects (Pythagoras) Use distance between objects for collision detection purposes Change game state based on game sprites positions in game world Give sprites speed and a known direction (Trigonometry SOH CAH TOA ) Use atan2 to follow or point at moving sprite In 3D games, math is used to orientate objects in three coordinate systems x,y,z Used to construct formulae which implements sprite behaviours for physics - such as acceleration, momentum, friction.

UFCEKU-20-3Web Games Programming The Prime Numbers The distribution of Prime numbers is the most important unanswered question in Mathematics - can you find a formula to say if a given number is a Prime number? 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 If you can you will probably win a Nobel prize and be famous forever! A Prime number is only divisible by 1 and itself