I’m trying to rotate a triangle on a coordinate grid by a given angle around a center that is not the origin. My plan is to translate so the center moves to the origin, rotate, then translate back. But when I plot the result, the image sometimes looks mirrored or it’s consistently shifted. I’m not sure if I’ve got the sign convention wrong for clockwise vs counterclockwise, or if I’m mixing up the order of the translations. I also worry I might be using degrees in one place and radians in another. Could someone clarify the correct sequence of steps, the sign to use for a clockwise angle, and any common pitfalls when the center is outside the shape? A small checklist would help me see where I’m going wrong. Any help appreciated!
Welcome to Maths For Fun – where mathematical curiosity meets pure enjoyment for learners of all ages! Founded by a team of lifelong maths enthusiasts, we believe that numbers aren’t just for tests – they’re for exploration, discovery, and delight. Whether you’re eight or eighty, a beginner or a seasoned problem solver, you’ll find a growing collection of logic based games and puzzles that cover every corner of mathematics.
















4 Responses
Do this every time: with point p=(x,y) and center c=(a,b), compute p’ = R(θ)(p−c)+c where R(θ) = [[cosθ, −sinθ],[sinθ, cosθ]] (θ in radians, CCW positive; for clockwise use −θ or [[cosθ, sinθ],[−sinθ, cosθ]]); checklist: subtract c, rotate, then add c back. If it looks mirrored/shifted, you likely mixed degrees/radians, reversed the translate order, used screen coords with y downward (flip sin), or rounded trig too early-what center and angle are you using so we can test one vertex?
Think of it like: shift the center C=(cx,cy) to the origin, rotate counterclockwise by θ, then shift back-algebraically P’ = C + Rθ(P−C) with Rθ=[[cosθ, −sinθ],[sinθ, cosθ]], and clockwise just means use −θ; this works no matter where C is.
Quick checklist: subtract C, apply Rθ, add C; use radians for sin/cos; keep the order exactly; check the −sin/+sin signs; beware screen coords with y increasing downward (flips apparent direction); and don’t round early-does that match what you’re doing, or want to share one point/angle to sanity‑check together?
I picture this like pinning a paper triangle with a pushpin that isn’t at its center and giving it a spin. The algebra version is: shift the world so the pin is at the origin, spin, then shift back. If your triangle has a point (x, y) and your center is (h, k), the clean one-shot formula for a counterclockwise rotation by angle θ is:
x’ = cosθ·(x − h) − sinθ·(y − k) + h
y’ = sinθ·(x − h) + cosθ·(y − k) + k
That “subtract the center, rotate, add the center back” rhythm prevents the wandering/shifted result. Also, most code libraries want θ in radians, so if you’re thinking in degrees, convert first. Clockwise vs counterclockwise: standard math takes θ > 0 as counterclockwise, so a clockwise turn by α is the same as using θ = −α.
Quick sanity checks I use: plug θ = 0 and make sure you get the same point back; plug θ = 90° and see if (x − h, y − k) becomes (−(y − k), x − h). If your picture looks mirrored, it’s usually because the rotation matrix got a sign or swap mixed up (accidentally using [cosθ sinθ; −sinθ cosθ] or flipping the wrong sign), or the translations were applied in the opposite order. On the other hand, you can also do clockwise by “keeping θ positive and negating both sine and cosine,” though that can make the matrix act like a reflection if the translations are off, which is why I prefer the safer θ = −α route. One more gotcha: on screen coordinates where y grows downward, what looks clockwise on paper can appear reversed, so be consistent about your axis direction.
What angle and center are you using, and are you working in a standard math grid or a screen-style grid where y increases downward?
Shimmy the points by subtracting the center, spin with Rθ = [[cosθ, −sinθ],[sinθ, cosθ]], then shimmy back: p’ = c + Rθ(p − c); by the usual screen-style sign convention, clockwise is +θ and counterclockwise is −θ, and common gremlins are mixing degrees/radians, swapping the sin signs (causes a mirror), or adding c before the spin (causes a shift). What center and angle did you try, and does p’ = c + Rθ(p − c) tame the shape’s little twirl?