Jump to content
  • Advertisement
Sign in to follow this  
xraven13

Center of rotated object in space if i have origin of center and top left coordinates

This topic is 3050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Picture of problem : http://i47.tinypic.com/r2vvxd.png So x and y of sprite is top left of the sprite. Origin.x and origin.y are relative to the sprite (origin values don't change how sprite flies around and rotates) and they are center of rotation. Sprite ( ship ) is moving left,right,up, down and it also rotates around its center point (origin). What i need is the value of its center in 2D coordinate system.. I also have angle of ship... So how to get coordinates of its center if ship flies around and rotates? Thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement
The center point x would be its x position plus the width of the sprite divided by 2.

The center point y would be its y position plus the height of the sprite divided by 2.

int centerPointX = xPosition + (imageWidth / 2)
int centerPointY = yPosition + (imageHeight / 2)

Share this post


Link to post
Share on other sites
That doesn't work because sprite is rotated...;) That was first thing i tried :p..

And btw my origin is equal to :
Origin.x = width/2;
Origin.y = height/2;
It doesn't matter but..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!