Rotating a point about another point 2D
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
Rotating one point around another point in 2D is a standard coordinate-transformation problem. The solution is always the same: translate the point so the pivot sits at the origin, apply the rotation, and translate back. Once you understand those three steps, the formula becomes easy to remember and implement.
The Three-Step Geometry
Suppose you want to rotate point (x, y) around pivot (cx, cy) by an angle measured in radians.
The process is:
- subtract the pivot so the pivot becomes the temporary origin
- apply the 2D rotation formula
- add the pivot back
If the translated coordinates are:
- '
tx = x - cx' - '
ty = y - cy'
then the rotated translated coordinates are:
- '
rx = tx * cos(angle) - ty * sin(angle)' - '
ry = tx * sin(angle) + ty * cos(angle)'
and the final answer is:
- '
final_x = rx + cx' - '
final_y = ry + cy'
That is the whole transformation.
A Python Implementation
Output:
This rotates (1, 0) around the origin by 90 degrees counterclockwise.
A C# Implementation
This follows the same math directly and is easy to reuse in graphics, UI, or game code.
Degrees Versus Radians
Most programming language math libraries expect the angle in radians, not degrees. If your input is in degrees, convert it first.
Forgetting this is one of the fastest ways to get a result that “looks almost random” even when the formula is correct.
Clockwise Versus Counterclockwise
The standard formula above rotates counterclockwise for positive angles in the usual Cartesian coordinate system. If your screen coordinates have the y-axis growing downward, the visual result may appear flipped compared with textbook geometry.
That does not mean the formula is wrong. It means your coordinate system is different from the mathematical one. In screen-space systems, you often need to negate the angle or adjust the interpretation.
Common Pitfalls
- Rotating around the origin when the real pivot is somewhere else.
- Forgetting to translate the point to and from the pivot.
- Passing degrees into
sinandcoswhen the math library expects radians. - Expecting screen coordinates to behave exactly like Cartesian coordinates.
- Rounding too early and accumulating visible error over many repeated transformations.
Summary
- Rotate around another point by translating to the pivot, rotating, and translating back.
- The core formula uses
cosandsinon the translated coordinates. - Most code libraries expect the angle in radians.
- Positive angles are usually counterclockwise in Cartesian coordinates.
- If the result looks mirrored on screen, check whether your y-axis direction differs from standard math coordinates.
Related reading
- Round number to nearest integer
- Round to the nearest power of two
- Rounding to an arbitrary number of significant digits
- Rounding to nearest 100
- Rounding up to the nearest multiple of a number
- RuntimeError size mismatch m1 a x b, m2 c x d
- Scaling an iterative, bitwise algorithm to solve the Towers of Hanoi using X discs and Y towers
- Scikit-Learn Decision Tree Probability of prediction being a or b?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.