How do I able to calculate these angles?

  • Hello!

    Please help me.

    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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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..)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)