Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: set coordinates depending on rotation  (Read 1239 times)

0 Members and 1 Guest are viewing this topic.

Dannehood

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
set coordinates depending on rotation
« on: July 02, 2012, 11:48:30 am »
I am currently working on collision detection/effect with triangles and I've got it to work if they are not rotating..

I have made 2 variables for each corner, one for x and y. The problem I'm having is that when you rotate the triangle the values of the corners stays the same (they are not targeting the corners anymore therefor the collision detection function I have made does not work). So I tried to make it so that those values depend on what the rotation is. The radius of the triangle is 64 and the top corner is right in the center so I thought that if the rotation was 90 degrees the x values should be - 64. With that in mind I came up with this: x = center of triangle - (rotation/1.40625) the 1.40625 is 90/64. This indeed made it so that when the rotation was 90 the value of x was - 64, I later realized that I had made a line instead of a curve.

So how do I make x and y coordinates make the same curve as the rotation?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: set coordinates depending on rotation
« Reply #1 on: July 02, 2012, 11:56:19 am »
If the triangle is a SFML entity, you can retrieve its transform and apply it to the local points to get their final position after all transformations have been applied to them, which includes translation, rotation and scaling.

You should give more information, we don't even know which version of SFML and which classes you work with.
Laurent Gomila - SFML developer