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.

Slides:



Advertisements
Similar presentations
Trigonometric Functions
Advertisements

UFCEKU-20-3Web Games Programming Game Math. UFCEKU-20-3Web Games Programming Agenda Revise some basic concepts Apply Concepts to Game Elements.
Section 10.1 Tangent Ratios.
Trigonometry A brief review. 1.4 Trigonometry.
Quadratic & Polynomial Functions
5/5/ : Sine and Cosine Ratios 10.2: Sine and Cosine Expectation: G1.3.1: Define the sine, cosine, and tangent of acute angles in a right triangle.
Honors Geometry Section 10.3 Trigonometry on the Unit Circle
Vectors and Oblique Triangles
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
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.
The World’s Largest Ferris Wheel
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
EXAMPLE 1 Finding Trigonometric Ratios For PQR, write the sine, cosine, and tangent ratios for P. SOLUTION For P, the length of the opposite side is 5.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Where you see the picture below copy the information on the slide into your bound reference.
Sine, Cosine and Tangent Ratios Objective Students will be able to use sine, cosine, and tangent ratios to determine side lengths in triangles.
Copyright  2011 Pearson Canada Inc. Trigonometry T - 1.
Right Triangles and Trigonometry
1 Circular Functions Just a fancy name for Trigonometry –Thinking of triangles as central angles in a circle Have done trigonometry ever since grade 9.
Chapter 3 Working with Symbols and Interactivity.
Unit 8 Trigonometric Functions Radian and degree measure Unit Circle Right Triangles Trigonometric functions Graphs of sine and cosine Graphs of other.
Chapter 4.1 Mathematical Concepts
Right Triangle Trigonometry
Chapter 6 ADDITIONAL TOPICS IN TRIGONOMETRY. 6.1 Law of Sines Objectives –Use the Law of Sines to solve oblique triangles –Use the Law of Sines to solve,
Topic 1 Pythagorean Theorem and SOH CAH TOA Unit 3 Topic 1.
Locating Points on a Circle Sine Cosine Tangent. Coordinates Systems Review There are 3 types of coordinate systems which we will use: Absolute Incremental.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 3 "The games of a people reveal.
Slide 8- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Forces in 2D Chapter Vectors Both magnitude (size) and direction Magnitude always positive Can’t have a negative speed But can have a negative.
Vector Quantities We will concern ourselves with two measurable quantities: Scalar quantities: physical quantities expressed in terms of a magnitude only.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 3 "The games of a.
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.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 2 "The games of a.
January 23, 2006Vectors1 Directions – Pointed Things January 23, 2005.
CHAPTER 5 FORCES IN TWO DIMENSIONS
VECTORS. Pythagorean Theorem Recall that a right triangle has a 90° angle as one of its angles. The side that is opposite the 90° angle is called the.
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.
 To add vectors you place the base of the second vector on the tip of the first vector  You make a path out of the arrows like you’re drawing a treasure.
Programming games Show your version of Bo the dog. Start cannonball Preview: video, audio work session (cannonball) Homework: Cannonball with ball in a.
Chapter 3 – Two Dimensional Motion and Vectors
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script "The games of a people reveal.
Vectors AdditionGraphical && Subtraction Analytical.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Sound in Action Script "The games of a people reveal.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 6 "The games of a people reveal.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 3 "The games of a people reveal.
Kinematics in Two Dimensions. Section 1: Adding Vectors Graphically.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
Vectors have magnitude AND direction. – (14m/s west, 32° and falling [brrr!]) Scalars do not have direction, only magnitude. – ( 14m/s, 32° ) Vectors tip.
Warm- up What do you remember about right triangles?
Today, we will have a short review on vectors and projectiles and then have a quiz. You will need a calculator, a clicker and some scratch paper for the.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Action Script 12 "The games of a people.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 12 "The games of.
Resolution and Composition of Vectors. Working with Vectors Mathematically Given a single vector, you may need to break it down into its x and y components.
VECTORS. BIG IDEA: Horizontal and vertical motions of an object are independent of one another.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script "The games of a people.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
WARM UP Write the general equation of an exponential function. Name these Greek letters β, θ, Δ, ε What transformation of the pre-image function y = x.
Vectors Vectors or Scalars ?  What is a scalar?  A physical quantity with magnitude ONLY  Examples: time, temperature, mass, distance, speed  What.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 11 "The games of a people reveal.
Lesson 8-6 The Sine and Cosine Ratios (page 312) The sine ratio and cosine ratio relate the legs to the hypotenuse. How can trigonometric ratios be used.
How can you apply right triangle facts to solve real life problems?
Trigonometry bouncing_ball.py
Geometry Lesson 8 – 4 Trigonometry Objective:
Physics Ch.3 Vectors.
Working with Symbols and Interactivity
Programming games Demonstrate cannonball
Trigonometric Ratios Geometry.
Presentation transcript:

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 a great deal about them.“ Marshall McLuhan

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Keyboard detection Flash allows to detect events occurring from keypresses Key class handles the detection of key presses Navigation based on the keyboard arrow keys number keys Keyboard shortcuts to duplicate mouse – based interaction Control live text real time type in the movie

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Keyboard detection keyobject.fla Open keyobject.fla file, study the timeline and add the following code in the first fame. if (Key.isDown(Key.SPACE)) { gotoAndStop(10); } isDown checks if key is pressed Returns true if yes Try different keys from the ActionScripts 2.0 classes > Movie > Key > Constants

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Keyboard detection 02twokeys.fla Open 02twokeys.fla file, study the timeline and add the following code in the first fame. if (Key.isDown(Key.SPACE) && Key.isDown(Key.CONTROL)) { gotoAndStop(10); } && logical operator returns true if both operands are true Try different keys and test the movie

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Keyboard detection 03KeyPressbutton.fla Before Key class in Flash players 6 and lower event handlers were used Open 03KeyPressbutton.fla and apply the following script to button1: on (keyPress " ") { nextFrame(); } on (keyPress " ") { prevFrame(); }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Key Listener 04KeyListener.fla Key Listener object “listens for” events from keys Open 04KeyListener.fla and apply the following script to the first frame: stop(); myListener = new Object(); myListener.onKeyDown = function() { gotoAndStop(5); } Key.addListener(myListener); Whenever keyDown event occurs the listener object is notified

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Key Listener 04KeyListener.fla Listeners are required for the events of the Key Selection TextField Stage classes. You can combine Key listener with isDown () method to make Flash respond only to certain keypresses. First the listener detects where the key is pressed. Then you can use if statement to test where the certain key has been pressed.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Key Listener 05KeySpaceListener.fla myListener = new Object(); //the object myListener is created to detect events from the Key class myListener.onKeyDown = function() { //onKeyDown event is assigned to myListener if (Key.isDown(Key.SPACE)) { gotoAndStop(5); } //when myListener detect SPACE key pressed Flash goes to frame 5 and stops there. Key.addListener(myListener); // registers myListener to the Key class

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Key Listener 05KeySpaceListener.fla Open 05KeySpaceListener.fla and apply the following script for the first frame: stop(); myListener = new Object(); myListener.onKeyDown = function() { if (Key.isDown(Key.SPACE)) { gotoAndStop(5); } Key.addListener(myListener);

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Sine and Cosine for directional movement 06sine_cosine.fla Open 06sine_cosine.fla and apply the following script for the first frame: _root.onEnterFrame = function() { if (Key.isDown(Key.LEFT)) { car_mc._rotation -= 10; } else if (Key.isDown(Key.RIGHT)) { car_mc._rotation += 10; } var myAngle:Number = 90 - car_mc._rotation; xchange= Math.cos(Math.PI / 180 * myAngle) * 5; ychange = -Math.sin(Math.PI / 180 * myAngle) * 5; car_mc._x += xchange; car_mc._y += ychange; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla Trigonometry is the study of triangles. Why Learn Trigonometry? To find the distance between two points or make an object move Rotating a spaceship or other vehicle Properly handling the trajectory of projectiles shot from a rotated weapon Calculating a new trajectory after a collision between two objects such as billiard balls or heads Determining if a collision between two objects is happening Finding the angle of trajectory (given the speed of an object in the x direction and y direction)

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla Knowing the length of any two sides of a right triangle is enough information to calculate the other two sides of a right triangle. This is useful when you need to find the cosine, sine, and tangent of a triangle. why do you need to find the cosine, sine, and tangent of a triangle? to calculate points around a circle Some examples of problems involving triangles and angles the forces on an aircraft in flight the application of torques and the resolution of the components of a vector

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla A right triangle is a three sided figure with one angle equal to 90 degrees. A 90 degree angle is called a right angle which gives the right triangle its name. We pick one of the two remaining angles and label it c and the third angle we label d. The sum of the angles of any triangle is equal to 180 degrees. If we know the value of c, we then know that the value of d: 90 + c + d = 180 d = c d = 90 - c

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla We define the side of the triangle opposite from the right angle to be the hypotenuse. It is the longest side of the three sides of the right triangle. The word "hypotenuse" comes from two Greek words meaning "to stretch", since this is the longest side. We label the hypotenuse with the symbol h. There is a side opposite the angle c which we label o for "opposite". The remaining side we label a for "adjacent". The angle c is formed by the intersection of the hypotenuse h and the adjacent side a.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla the relations between the sides and the angles of the right triangle the ratio of the opposite side of a right triangle to the hypotenuse is called the sine (sin ) sin = o / h

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla The ratio of the adjacent side of a right triangle to the hypotenuse is called the cosine (cos ) cos = a / h

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla To control how far object moves on the stage based on its angle racing game with car driving along the track travels at certain speed and moves to the front direction Calculating how far car moves in any direction requires Math.sin() and Math.cos() methods.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla The new location of the car is determined by the x and y components of the triangle formed by the angle of the car.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla When car is pointing straight up, the y = 1 and x = 0 When car is pointing to the right, the y = 0 and x = 1 When the car is somewhere between, the sin and cos of the triangle will give the x and y coordinates

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla Sin and cos are based on the angles that begin at 0 degrees from horizontal axis The rotation of car is based on the angles that begin at 0 degrees from vertical axis

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla The y for sin function is positive + above the origin of the circle Negative below the origin of the circle

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla To deal with movie clips coordinate space must make 2 transformations: subtract the rotation property from 90 to get the angle for sin and cos Use the negative value of sin for the change in vertical y direction: myAngle = 90 - car_mc._rotation;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla Open 06sine_cosine.fla file and enter the following script for the first frame: _root.onEnterFrame = function() { if (Key.isDown(Key.LEFT)) { car_mc._rotation -= 10; // the car_mc movie clip rotates 10 degrees CCW when the left arrow key is pressed } else if (Key.isDown(Key.RIGHT)) { car_mc._rotation += 10; } // the car_mc movie clip rotates 10 degrees CW when the right arrow key is pressed

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla myAngle = 90 - car_mc._rotation; // variable myAngle is used as the angle for sin and cos

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla myAngle = 90 - car_mc._rotation;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla y sin (myAngle ) = x cos (myAngle ) =

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla y sin (myAngle ) = --y = sin (myAngle ) * 1 y = sin (myAngle ) 1 x cos (myAngle ) = --x = cos (myAngle ) *1 x = cos (myAngle ) 1

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla y = sin (myAngle ) x = cos (myAngle ) xchange= Math.cos(myAngle) ; ychange = -Math.sin(myAngle) ; xchange= Math.cos(Math.PI / 180 * myAngle) * 5; ychange = -Math.sin(Math.PI / 180 * myAngle) * 5;

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla xchange= Math.cos(Math.PI / 180 * myAngle) * 5; //cos of the movie clip’s angle is calculated and passed to xchange Math.cos (myAngle) cos of myAngle Math.cos (Math.PI / 180 * myAngle) converts myAngle from degrees to radians Math.cos(Math.PI / 180 * myAngle) * 5 Multiplying by 5 increases the magnitude of the change so that movie clip moves a little faster

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla ychange = -Math.sin(Math.PI / 180 * myAngle) * 5; //the negative sin of the movie clip’s angle is calculated and passed to ychange

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla car_mc._x += xchange; car_mc._y += ychange; // as the movie clip of the car rotates, the x and y components are calculated from cosine and sine and the cars new position is defined. }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Trigonometry 06sine_cosine.fla _root.onEnterFrame = function() { if (Key.isDown(Key.LEFT)) { car_mc._rotation -= 10; } else if (Key.isDown(Key.RIGHT)) { car_mc._rotation += 10; } myAngle = 90 - car_mc._rotation; xchange= Math.cos(Math.PI / 180 * myAngle) * 5; ychange = -Math.sin(Math.PI / 180 * myAngle) * 5; car_mc._x += xchange; car_mc._y += ychange; }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Calculating angles Knowing the length of any 2 sides of the right triangle is enough info to calculate the other two angles. The length of the opposite is often X The length of the adjacent is often Y

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Calculating angles We can calculate the x and y coordinates of the point Once we have x and y coordinates we can calculate the angle (theta) Using tangent (tan) Tan (theta) = opposite / adjacent Tan (theta) = y / x Theta = arctan (y / x)

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Calculating angles Theta = Math.atan ( this._y / this._x) Flash provides even easier function to define x and y position without the division the atan2() Atan2 ()accepts x and y positions as two parameters to calculate the theta angle Theta = Math.atan2(this._y, this._x)

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Calculating angles Theta = Math.atan2(this._y, this._x) Math returns the value of an angle in radians Which describe angles in terms of the constant pi To use this value to modify the _rotation property we need to convert it radians to degrees

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Calculating angles to convert it radians to degrees: radians = Math. PI / 180 * degrees degrees = radians * 180 / Math. PI

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Calculating angles 07point2stageangle.fla Calculating the angle of a draggable movie clip relative to either the stage or another point and display an angle in degrees in a dynamic text field. Angle relative to the stage 07point2stageangle.fla Note that movie clip called circle_mc Note that dynamic text field called myDegrees_txt Apply the following script to the first frame

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla circle_mc. startDrag ( true ) ; StartDrag () makes the movie clip circle_mc follow the pointer and centers it on the pointer

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla _root.onEnterFrame = function() { myRadians= Math.atan2(circle_mc._y, circle_mc._x); Flash calculates the arc tangent of the y position of the movie clip divided by the x position of the movie clip and returns the value in radians.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla myDegrees_txt.text = (myRadians * 180 / Math.PI) + "degrees"; (myRadians * 180 / Math.PI ) converts radians to degrees The angle is converted from radians to degrees and assigned to to the contents of the dynamic text field myDegrees_txt with the word “degrees” concatenated

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla _root.clear(); _root.lineStyle(1, 0x000000, 100); _root.beginFill(0xff0000, 30); _root.moveTo(0, 0); _root.lineTo(circle_mc._x, circle_mc._y); _root.lineTo(circle_mc._x, 0); } Draws the line _root.clear (); erases the previous drawing on a movie clip

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla _root.lineStyle(1, 0x000000, 100);changes the characteristics of your line, such as its point size, color (hex) and transparency LineTo(); set the end point beginFill();fills shapes with solid color according to 2 parameters, color(hex) and transparency MoveTo(); sets the beginning point of your line or curve like placing pen on paper

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla As the player moves pointer around the stage the movie clip follows the pointer. Flash calculates the angle that the movie clip makes with the x-axis or the root Timeline and displays it in the dynamic text field.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to the stage 07point2stageangle.fla circle_mc.startDrag(true); _root.onEnterFrame = function() { myRadians= Math.atan2(circle_mc._y, circle_mc._x); myDegrees_txt.text = (myRadians * 180 / Math.PI) + " degrees"; // // draw lines to show triangle // _root.clear(); _root.lineStyle(1, 0x000000, 100); _root.beginFill(0xff0000, 30); _root.moveTo(0, 0); _root.lineTo(circle_mc._x, circle_mc._y); _root.lineTo(circle_mc._x, 0); }

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to another point 07point2stageangle.fla To calculate angle relative to another point Drag a new movie clip instance to the stage, name it “RefPoint”

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to another point 07point2stageangle.fla _root.onEnterFrame = function() { myRadians = Math.atan2((circle_mc._y - RefPoint_mc._y), (circle_mc._x - RefPoint_mc._x)); By subtracting the x and y positions of the RefPoint from the draggable movie clip positons, Flash calculates the x and y distances between 2 points.

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to another point 07point2stageangle.fla The difference between the y positions of the circle_mc and RefPoint is the y parameter for Math.atan2() The difference between the x positions of the circle_mc and RefPoint is the x parameter for Math.atan2()

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to another point 07point2stageangle.fla Often we need to round off decimal values to the nearest whole number (integer) so that they can be used as parameters for properties. Math.round() rounds the value to the nearest integer Math.ceil() rounds the value to the nearest integer greater than or equal to the value Math.floor() rounds the value to the nearest integer less than or equal to the value

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to another point 07point2stageangle.fla myDegrees_txt.text = Math.round(myRadians * 180 / Math.PI) + " degrees"; The Expression is rounded to the nearest integer and displayed in the dynamic text filed myDegrees_txt

AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Angle relative to another point 07point2stageangle.fla circle_mc.startDrag(true); _root.onEnterFrame = function() { myRadians = Math.atan2((circle_mc._y - RefPoint_mc._y), (circle_mc._x - RefPoint_mc._x)); myDegrees_txt.text = Math.round(myRadians * 180 / Math.PI) + " degrees"; _root.clear(); _root.lineStyle(1, 0x000000, 100); _root.moveTo(RefPoint_mc._x, RefPoint_mc._y); _root.lineTo(circle_mc._x, circle_mc._y); }