# How do I calculate object relation to each other via angle?

Get help using Construct 2

### » Mon Sep 18, 2017 6:10 pm

Hello! I have too trucks and, to calculate collisions and such, I need a reliable system to measure their angle difference. Then, If angle difference = x, I know that one car is, say, perpendicularly against second truck's side.

Is it even possible in construct, since angles go from -∞ to +∞?
I've tried to come up with my own formula, but I am a bit unsure with the results.
B
6
S
3
Posts: 139
Reputation: 1,666

### » Mon Sep 18, 2017 7:44 pm

you can use the bbox top and bottom of the standing truck, and measure between angle of those positions its a bad solution though to play with angles. better use distance.
B
83
S
25
G
70
Posts: 1,373
Reputation: 44,861

### » Mon Sep 18, 2017 9:39 pm

There is the angleDiff(a,b) expression that will do that. It gives a value of 0 to 180.
If you need a signed angle result of -180 to 180 you can do angle(0,0,cos(a-b),sin(a-b))
B
98
S
36
G
131
Posts: 5,521
Reputation: 83,505