Calculating the angle between 2 movies clips

Hi,
How can I calculate the angle made by 2 movie clips. Each one represent a line.
Thanks,

you need a little trig

basically you have 2 points startpoint(x = 0 , y= 0(sample values)) and end point (x = 20 , y =10)

to find the angle you have to start byt drawing a right triangle

ignore the numbers 15/20 as those are not valid for this explanation
Point B is your start point(pretend its 0,0) Point A is your end point(20,10)
x would be the angle from A to B

the Slanted line is the Hypotinus (sp? )(edge BA)
the BC edge is the OPPOSITE EDGE of the angle were trying to find
the AC edge is the ADJACENT Edge

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,10) 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 - 10)^2)
DistanceOpposite = Math.sqrt((0)^2 +(-10)^2)
DistanceOpposite = Math.sqrt((00)+(-10-10))
DistanceOpposite = Math.sqrt(100)
DistanceOpposite = 10

DistanceAdjacent = Math.sqrt((Start.x -End.x)^2 +(End.y - End.y)^2)
DistanceAdjacent = Math.sqrt((0-20)^2 +(10-10)^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(10/20)
Angle = Math.atan2(0.5)
Angle = (about ) 26.56 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.PIdegrees)/180
degrees = 180 /(Math.PI
radians)

[edit] this function should work
Q_Hybrid posted it on flashkit

Joran, is this your explanation?

yeh

I was trying to do it the other day so i learned some trig

hehe btw hey nathan can you look at my code(its a couple threads down…the one that says stumped please look at my code)

and see if you can gimme a better idea on how to make sure the shot ball places itself right

Whow ! :hugegrin:
Thanks !