Compute the exact coordinates of the four corners of any rotated rectangle. Enter center (cx, cy), width (w), height (h), and rotation angle (θ). Visualize the rectangle, its vertices, and the center on an interactive canvas.
In Euclidean geometry, a rectangle is defined by its center (cx, cy), width w, height h, and rotation angle θ. The four corner points in the rectangle’s local coordinate system (aligned with axes) are: (-w/2, -h/2), (w/2, -h/2), (w/2, h/2), (-w/2, h/2). Applying a 2D rotation matrix and translating by the center yields the global corner coordinates.
Rotation matrix R(θ) = \begin{bmatrix} \cosθ & -\sinθ \\ \sinθ & \cosθ \end{bmatrix}
For any local point (x', y'), global point: (x, y) = (cx, cy) + R(θ)·(x', y')
Therefore each corner Pi = center + (x'i·cosθ - y'i·sinθ, x'i·sinθ + y'i·cosθ).
The concept of rotating rectangles is central to analytical geometry and computer graphics. The use of rotation matrices dates back to Euler and Rodrigues in the 18th century. Today, rotated rectangle corner calculations are indispensable in collision detection (separating axis theorem), 3D rendering (billboarding), robotic path planning, geographic information systems (GIS) for oriented bounding boxes, and even in structural engineering to compute rotated cross‑section properties. Mastering these transformations allows developers and engineers to build robust spatial algorithms.
1. Local coordinates: For a rectangle centered at origin, corners are (±w/2, ±h/2). We define order: P₁ = ( w/2, -h/2) [bottom‑right in local], P₂ = ( w/2, h/2) [top‑right], P₃ = (-w/2, h/2) [top‑left], P₄ = (-w/2, -h/2) [bottom‑left].
2. Rotation: Multiply each local vector by rotation matrix R(θ) where θ is in radians (θrad = θdeg * π/180).
3. Translation: Add center (cx, cy) to each rotated vector to obtain world coordinates.
4. Bounding box (AABB): Find min/max of all four rotated corner x and y coordinates – essential for broad‑phase collision detection.
Our calculator uses double‑precision arithmetic and handles degenerate cases (non‑positive width/height) gracefully.
The following results are automatically generated by the tool and match theoretical calculations (validated with Wolfram Alpha and standard geometry libraries).
| Configuration | Center (cx, cy) | w × h | θ (deg) | Corner P₁ (bottom‑right) | Corner P₃ (top‑left) |
|---|---|---|---|---|---|
| Axis‑aligned square | (0,0) | 4×4 | 0° | (2.00, -2.00) | (-2.00, 2.00) |
| 45° rotated square | (0,0) | 4×4 | 45° | (2.828, 0.000) | (-2.828, 0.000) |
| Wide rotated 30° | (1,1) | 6×2 | 30° | (4.098, 1.634) | (-2.098, 0.366) |
| Portrait 60° | (0,0) | 2×5 | 60° | (2.665, -0.384) | (-2.665, 0.384) |
In a 2D racing game, a developer needs to check collisions between rotated cars (oriented bounding boxes). Using this calculator, the designer obtains the exact corner points of each car’s hitbox. Then they implement the Separating Axis Theorem (SAT). For example, Car A centered at (5,3) with w=2.2, h=1.0, θ=15°, and Car B at (7,4) with w=2.0, h=1.0, θ=−10°. The calculator instantly provides all vertices, enabling precise collision response. The visual graph helps debug overlapping conditions. This reduces development time and improves gameplay realism.
Unlike triangles, rectangles have a single center (intersection of diagonals) which remains invariant under rotation. The four corner points are symmetric around the center. The rectangle's orientation does not affect the centroid; only the position and rotation matrix change the vertices. The bounding box (AABB) is essential for spatial indexing (quadtrees, R‑trees) – our calculator outputs the axis‑aligned bounding box for each rotated rectangle.