# How do I get the angle without angle(x) or atan(x)?

0 Favourites
• 5 posts
• I'm try to understante how do i know the angle of two objects... I know about trigonometry.

I got the oppositive and the adjacent.

I got the the sine, consine and tanget.

But, i don't know how know the angle at the first point to second point.

Some one can help me?

• If you're trying to get the angle between to points, I'm pretty sure there's already a built in function. IIRC it's "angle(x1, y1, x2, y2)" where the X and Y correspond to the position of points 1 and 2 respectively.

• Why would you want to do it without angle() or atan()? Internally angle() uses atan anyway.

You could use an infinite power series to calculate atan() in radians without using atan.

Or another method is to use an array to lookup angles from tangent ratios, and using interpolation for the in between values. However this is only as precise as how many values are in the array, not to mention you'd need to populate the array beforehand.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Why would you want to do it without angle() or atan()? Internally angle() uses atan anyway.

You could use an infinite power series to calculate atan() in radians without using atan.

Or another method is to use an array to lookup angles from tangent ratios, and using interpolation for the in between values. However this is only as precise as how many values are in the array, not to mention you'd need to populate the array beforehand.

I got it! I just want to understand how to get the angle... I use and i like to use atan(x) and angle(x), but i wanted to what it does. Anyway thanks!

• Tangent: Given an angle, will return the ratio of the opposite edge over the adjacent edge.

Arctan: Is the inverse of tangent, you input the ratio (based on difference between x and y coordinates of your two points), and get the angle.

The angle expression is a shortcut that uses atan(), except you input the actual coordinates instead of the ratio.

So angle(0,0,10,20) is equal to atan(2). (Difference in Y is your opposite value 20, difference in X is 10 would be your adjacent value. 20/10 would be your ratio of 2).

Alternatively, you can look at it as angle(ax,ay,bx,by) = atan((by-ay)-(bx-ay))