1. Rotating text (basic high school geometry) [SOLVED]

Consider the following zoomed-in diagram:

  +..W..9  TEXT 
  :  |  : 
  :     : 

Where TEXT is shown in its unrotated position, bounded by = and |.
The raw API rotate about the northwest corner, here denoted N, but I want to rotate about some other logical point, here we'll consider west, denoted W above.
[There are nine such similar logical points: NW, N, NE, W, C, E, SW, S, and SE.]
The . and : show the bounds of text rotated 90 about W, so to effect that I moved N to 9.
For 90 (only) I drew nine diddy-diagrams and figured out the shift needed to N, which were all +/- (width or height) [/2], some both.
Also shown above, bounded by - and |, is text rotated 180 about W, and to achieve that I would want to shift N to 1.

My question is: What is the easiest maths to shift N to effect such rotations, by any angle about any of the nine points?
Clearly to rotate 45 about W, I'd want to shift N to the mid-point between N and 9 on a circle with centre W.
In fact, of course, all rotations about W would first shift N to some point on that circle, and similar for the other eight.
Presumably it is all just a bit of sin() and cos(), maybe some matrix stuff?

Update: That quickly turned into a classic case of confessional debugging! I didn't twig until writing that down that
N would always be on a circle, which led me to search for "rotate point about another point", and bobs your uncle.

new topic     » topic index » view message » categorize

2. Re: Rotating text (basic high school geometry) [SOLVED]

Glad you solved it, Pete. I know rubber duck debugging can be really helpful for me.

For clarity's sake, you're talking about rotating 2D points on a plane for graphical text? (or just the origin point of the text)

Or are you trying to rotate a matrix of characters, like this? (where X is the pivot point, and thole thing is rotated 90° clockwise)

"         "    " X " 
"X    TEXT" -> "   " 
"         "    "   " 
               "   " 
               "   " 
               " T " 
               " E " 
               " X " 
               " T " 


new topic     » goto parent     » topic index » view message » categorize

3. Re: Rotating text (basic high school geometry) [SOLVED]

I hadn't though about that. I guess you'd want to rotate the centres of the letters along an ellipse?
The other one would be a full set of rotateable 3D letters, but I doubt there's any neat shortcut to that...

new topic     » goto parent     » topic index » view message » categorize


Quick Links

User menu

Not signed in.

Misc Menu