How do I able to calculate these angles?

Just started using Construct 2? Post your questions here

Post » Fri Sep 04, 2015 10:54 am

Hello!

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

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...:oops:

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

Post » 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
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » 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! :D

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


Return to Beginner's Questions

Who is online

Users browsing this forum: FartsLolz and 1 guest