- Home /
Finding the center of a rotating image.
So, I'm attempting to do some GUI tweening. Fun fun! But there's one bit of math I'm having trouble with. Maybe you know the answer? As it stands, I'm rotating, scaling, moving, and fading a rectangularly shaped image (it must be rectangular, can't make it square). And everything's going well, but the pivot point is off the more I rotate. I know this because when I turn off the RotateAroundPivot command, the image appears to move correctly--whereas it does strange things when I use it. So, the question is this:
Given the upper left pixel coordinate and the width and height of an image, how do you calculate its pivot point? I get the feeling there's some heavy trig to be considered here.
For example:
At one point, the rectangle will be rotated 17 degrees to the left (-17 degrees in Unity). Where is the pivot point (the center of the rectangle), in reference to the top left pixel coordinates?
Help and cheers,
Simon
Answer by DaveA · Nov 09, 2011 at 09:52 PM
Wouldn't the center be at width/2, height/2?
Well...No, not exactly all the time, right? Because if you have a rectangle standing tallways, then the center is left coord x + width/2, left coord y + height/2. But If you have it at 45 degrees counter-clock-wise, then using that same equation will give you the center, but only as though the rectangle were still standing straight up.
Right? It's got to be a different (more complicated) formula for this situation, right?
Cheers
SImon
Your answer
Follow this Question
Related Questions
How do you change the pivot point of a group? 1 Answer
How to transform/rotate a vector onto the same plane as another vector 2 Answers
How do I create runtime inputs? 0 Answers
Calculate mid angle position based on three points 1 Answer
Get 360-degree rotation in on-screen directional arrow? 0 Answers