//**************************************************************************** // Calculate Euclidean distance using Cartesian version of Pythagorean theorem //**************************************************************************** // //****************** //Single line method //****************** // // gamePiece1 & 2 are setup // // Calculate x & y difference between points then square each // to get distance between two points on a line. // Add them together & determine square root for Euclidean distance // //**************** //distanceAmount = Math.sqrt(Math.pow(gamePiece1.x - gamePiece2.x,2) + Math.pow(gamePiece2.y - gamePiece2.y,2)); //**************** // // //**************************************************************************** // Calculate Euclidean distance using Cartesian version of Pythagorean theorem //**************************************************************************** // //****************** //Three line line method //****************** // // Setup variables for three line method: // var xDiff:int; // var yDiff:int; // var distanceAmount:int; // // Calculate x & y difference between points. // Square the x & y difference then determine square root for Euclidean distance // //**************** //xDiff = dotOne.x - dotTwo.x; //yDiff = dotOne.y - dotTwo.y; //distanceAmount = Math.sqrt(Math.pow(xDiff,2) + Math.pow(yDiff,2)); //**************** // //***************************************************** // Calculate Euclidean distance using distance() method //***************************************************** // // distance() method returns the distance between two points, pt1 and pt2. // // Create two points equal to location of gamePiece 1 & 2 // Populate distance() method with two points to get distance between them // //**************** //var point1 = new Point(gamePiece1.x,gamePiece1.y); //var point2 = new Point(gamePiece2.x,gamePiece2.y); //distanceAmount = Point.distance(point1,point2); //**************** // //used math round when input into text field. This retains the original distanceAmount in case I need it elsewhere // //******************** //distanceValue.text = String(Math.round(distanceAmount)) + " pixels"; //********************