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

Get help using Construct 2

### » Wed Jul 13, 2016 7:59 pm

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?
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

### » Wed Jul 13, 2016 8:18 pm

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.
B
65
S
25
G
19
Posts: 307
Reputation: 14,041

### » Wed Jul 13, 2016 8:36 pm

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.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Wed Jul 13, 2016 8:43 pm

R0J0hound wrote: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!
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

### » Wed Jul 13, 2016 8:59 pm

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))
B
61
S
30
G
134
Posts: 1,973
Reputation: 75,448