Oh, trigonometry~

0 favourites
  • 5 posts
  • I never figured out trigonometry enough to solve this little problem I have.

    As you may know, when a layer rotates in construct, it rotates with its axis included, so the coordinates move with it, something like this:

    <img src="http://img707.imageshack.us/img707/5083/001sng.png" border="0" />

    <img src="http://img26.imageshack.us/img26/8682/002bcp.png" border="0" />

    Now, I need a formula that, knowing the angle of rotation of the layer, tells me the visual position of a point (in the example, I would want (0,y) instead of (x,y)).

    Any help would be greatly appreciated n__n!

    Edit: note that the point can move freely. So I need to know the absolute position of the point of its relative position in the rotated layer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • cx,cy are the coordinates of the center of rotation

    xR,yR are the coordinates in a rotated layer at angle layerangle

    x,y are the coordinates in an unrotated layer

    x = cx + cos(-layerangle) * distance(cx,cy,xR,yR)

    y = cy + sin(-layerangle) * distance(cx,cy,xR,yR)

  • It doesn't work because if the layer is not rotated (i.e. layerangle = 0), its sine = 0, so y = cy.

    :<

  • yeah your right

    x = cx + cos(-layerangle+angle(cx,cy,xR,yR)) * distance(cx,cy,xR,yR)

    y = cy + sin(-layerangle+angle(cx,cy,xR,yR)) * distance(cx,cy,xR,yR)

  • Thank you very much! It works now!

    You'll be in the credits of every game for the contest, it appears xD

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