# How do I able to calculate these angles?

Just started using Construct 2? Post your questions here

### » Fri Sep 04, 2015 10:54 am

Hello!

Since my English is terrible, I made a sample image.

A is a fixed point. If player clicked somewhere on the screen, that point will become B. So position of B differ each time. I want to know angle A and angle B for correctly place 2 bars (55 pixels and 70 pixels).

How do I able to calculate these 2 angles in the Construct2 way?
I think I learned these trigonometric things long time ago, but I can't remember now...

EDIT: I forgot to mention. I have already tried to use Physics(revolute joint). I think unpredictability of Physics is not suitable for my game(it's a turn-based strategy).

Thanks

Simano
B
6
Posts: 2
Reputation: 254

### » Fri Sep 04, 2015 5:40 pm

This is an inverse kinematics problem and can be solved with the law of cosines, which you can use to solve for the unknown angles.
Moderator
B
114
S
41
G
20
Posts: 1,586
Reputation: 19,161

### » Fri Sep 04, 2015 6:58 pm

I'm not sure but..

Angle A is:
acos(distance(A.X,A.Y,B.X,B.Y)*0.44/55)

Angle B is:
acos(distance(A.X,A.Y,B.X,B.Y)*0.56/70)

I tried these in C2 and they seem working.
Thank you!

I'll re-learn math again. (and English too, someday..)
B
6
Posts: 2
Reputation: 254