1. Rotating text (basic high school geometry) [SOLVED]
- Posted by petelomax Nov 03, 2023
- 855 views
Consider the following zoomed-in diagram:
-----N======== | +..W..9 TEXT : | : --:--1==:===== : :
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.
2. Re: Rotating text (basic high school geometry) [SOLVED]
- Posted by ghaberek (admin) Nov 03, 2023
- 852 views
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 "
-Greg
3. Re: Rotating text (basic high school geometry) [SOLVED]
- Posted by petelomax Nov 03, 2023
- 845 views
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...