Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Xna

  • 13-09-2013 11:18AM
    #1
    Registered Users, Registered Users 2 Posts: 3,500 ✭✭✭


    Hey I have a bit of a maths question that I need help with. Any help'd be great.

    Just messing around in Xna and messing with sprites and stuff/

    I have a square (a 48 * 48 image) which I can track on screen by the x and y of the top left point of the square. This is all fine. I want to be able to rotate the square and still keep track of the same point. for instance if I rotate 90degrees clockwise and the orginal X position was 200 the new X position should be 200 + 48(the size of the width of the image). Its fine for 90 degrees I am able to work that out in my head but each one in between is the problem! I know there is prob some kind of formula to work this out. Any help would be great! Oh the square is rotating on its center


Comments

  • Registered Users, Registered Users 2 Posts: 12,771 ✭✭✭✭Encrypted Pigeon


    If the square is rotating about the center as it is, why not do your calculations based on the center of the sprite?

    Anyway this (http://gamedev.stackexchange.com/a/18341 is one way of doing it, you know the radius and center of the sprite and angle you are rotating about the origin so simple trigonometry.

    Edit: fix link


  • Registered Users, Registered Users 2 Posts: 3,500 ✭✭✭Drexel


    CoderDozer wrote: »
    If the square is rotating about the center as it is, why not do your calculations based on the center of the sprite?

    Anyway this (http://gamedev.stackexchange.com/a/18341 is one way of doing it, you know the radius and center of the sprite and angle you are rotating about the origin so simple trigonometry.

    Edit: fix link

    Nice one. Thats exactly what I was looking for. I knew there was some way to work it out but wasnt sure what to google! Now to remember it all!!


Advertisement