QRec
QRec is an algorithm that helps you quickly find the largest fixed-aspect, axis-aligned rectangle that can be inscribed in any given polygon.
Install / Use
/learn @ivowang/QRecREADME
QRec
QRec is an algorithm that helps you quickly find the largest fixed-aspect, axis-aligned rectangle that can be inscribed in any given polygon.
Quick Start
Run 'python main.py' to find the rectangle that suits the polygon constructed from several homographies.
Algorithm
A largest inscribed rectangle ($R$) should have at least one conner alined to the edgd of the given polygon ($M$). Before the start, edges of the given polygon is calculated with Canny Edge Algorithm, that is, $E =canny(M)$, where notation $E$ representing the list of points in the edge dected by canny edging. Items in $E$ is shuffled to break the original order, increasing the randomness for later searches.
Searching process interates over the size of the rectangle. For each size of $[H_i, W_i]$, four rectangles are tested based on the edge set $E$. Specifically, for each point $[x_j, y_j]$ in $E$, we test the region of $[H_i\pm x_j, W_i\pm y_j]$. The size of $[H_i, W_i]$ will be accepted once there exists a region inscribed in $M$.
Searching will not end until there is a size with which no inscribed rectangle is found.
Related Skills
product-manager-skills
52PM skill for Claude Code, Codex, Cursor, and Windsurf: diagnose SaaS metrics, critique PRDs, plan roadmaps, run discovery, and coach PM career transitions.
pm
PM Agent Rule This rule is triggered when the user types `@pm` and activates the Product Manager agent persona.
devplan-mcp-server
3MCP server for generating development plans, project roadmaps, and task breakdowns for Claude Code. Turn project ideas into paint-by-numbers implementation plans.
