First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Joran420
OK so you have two distinct points and you want some basic info about them lets call them


(x = 0 , y = 0), and


(x = 20 , y = -15) (I know what original names!) To start with is your first leason(from me in trig

any two points can be connected to form 2 points on a right triangle.

so lets look at our right triangle(I just used some right triangle i found origianly with google images all credit goes to


is represented by Point B in the Picture


is represented by point A in the picture x would be the angle from A to B next lesson about a key concept in trig

any right triangle can be solved as long as you have 2 sides.

the Slanted line is the Hypotinus (sp? )(edge BA)is the distance of B to A the BC edge is the OPPOSITE EDGE of the angle were trying to find the AC edge is the ADJACENT Edge of our angle Any Angle in a right Triangle can be found usining Angle =tangent(Opposite/Adjacent) now were gonna need to figure out how long opposite and adjacent sides are Distance = SquareRoot((x1 -x2)^2 + (y1-y2)^2) the two points we know Start(0,0) End(20,-15) are points A and C so DistanceOpposite = Math.sqrt((Start.x -Start.x)^2 +(Start.y - End.y)^2) DistanceOpposite = Math.sqrt((0 -0)^2 +(0 - -15)^2) DistanceOpposite = Math.sqrt((0)^2 +(15)^2) DistanceOpposite = Math.sqrt((0*0)+(15*15)) DistanceOpposite = Math.sqrt(225) DistanceOpposite = 15 DistanceAdjacent = Math.sqrt((Start.x -End.x)^2 +(End.y - End.y)^2) DistanceAdjacent = Math.sqrt((0-20)^2 +((-15)-(-15))^2) DistanceAdjacent = Math.sqrt((-20)^2 +(0)^2) DistanceAdjacent = Math.sqrt((-20*-20) +(0*0)) DistanceAdjacent = Math.sqrt(400 +0) DistanceAdjacent = Math.sqrt(400) DistanceAdjacent = 20 so now we go back to our angle formula Angle =tangent(Opposite/Adjacent) Angle = Math.atan2(Opposite/Adjacent) Angle = Math.atan2(15/20) Angle = Math.atan2(0.75) Angle = (about ) 37 degrees [edit] actually i think on the atan2 Math function it devides it for you so it would be Math.atan2(Opposite,Adjacent) not Math.atan2(Opposite/Adjacent) Hopefully this helped i think all my math is right but if im wrong on anything im sure someone will correct it just remember flash when setting points tends to use radians rather than degrees radians = (Math.PI*degrees)/180 degrees = 180 /(Math.PI*radians) Ok if this didnt help...Q_Hybrid posted the following function for Actionscript here on Flashkit a while ago
» Level Intermediate

Added: 2006-04-27
Rating: 1 Votes: 1
(10 being the highest)
» Author
Just learned it for a program i was writing...figured id share...Someone on kirupa asked how to figure out an angle i answered with this..thought some ppl might find it useful
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.