Polygon measures compute
polygon-measures-compute · version 1.0.0 · Other utilities · free, no key needed
Compute exact signed double-area, area, orientation, and squared edge lengths for a rational simple polygon.
Use when you need to: compute exact polygon area · shoelace formula for rational coordinates · find polygon orientation.
Decide before calling
Read the versioned contract and the supported scope below. Reuse polygon-measures-compute@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use polygon-measures-compute@1.0.0 for compute exact polygon area. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- compute exact polygon area
- shoelace formula for rational coordinates
- find polygon orientation
- calculate signed double area
- squared lengths of polygon edges
- measure a simple polygon exactly
- polygon area without floating point
Not supported
- self-intersecting or degenerate polygons
- square-root perimeter approximation
- three-dimensional or curved geometry
Behavior
- Vertices are ordered boundary vertices; the closing edge from the last vertex to the first is implicit.
- Coordinates must be canonical reduced base-10 integers or p/q fractions with positive denominators and components no larger than 1000000000000000000.
- The polygon must be simple and nondegenerate; signed double-area is positive for counterclockwise order and negative for clockwise order.
- Area and each squared edge length are exact reduced rational strings; no floating-point approximation or rounding occurs.
- perimeter_squared_components follows edge order and includes the closing edge; it reports squared lengths rather than irrational square roots.
Input
vertices(array of object, required): min items 3; max items 128
Output
signed_double_area(string, required): min length 1; max length 256; pattern^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$absolute_area(string, required): min length 1; max length 256; pattern^(0|[1-9][0-9]*)(/[1-9][0-9]*)?$orientation(one of "counterclockwise", "clockwise", required)perimeter_squared_components(array of string, required): min items 3; max items 128; each min length 1; each max length 256; each pattern^(0|[1-9][0-9]*)(/[1-9][0-9]*)?$
Limits
- max input bytes: 20000
- max vertices: 128
- max coordinate bytes: 64
- max abs integer component: 1000000000000000000
- max output bytes: 40000
Example
Request input:
{
"vertices": [
{
"x": "0",
"y": "0"
},
{
"x": "4",
"y": "0"
},
{
"x": "0",
"y": "3"
}
]
}
Response:
{
"result": {
"signed_double_area": "12",
"absolute_area": "6",
"orientation": "counterclockwise",
"perimeter_squared_components": [
"16",
"25",
"9"
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "polygon-measures-compute",
"version": "1.0.0",
"input": {
"vertices": [
{
"x": "0",
"y": "0"
},
{
"x": "4",
"y": "0"
},
{
"x": "0",
"y": "3"
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/polygon-measures-compute/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"vertices":[{"x":"0","y":"0"},{"x":"4","y":"0"},{"x":"0","y":"3"}]}'
The machine-readable contract is at /v1/tools/polygon-measures-compute/versions/1.0.0.
CLI
node cli.mjs run polygon-measures-compute 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Geohash convert: Encode decimal coordinates as a bounded Geohash or decode a Geohash to its exact bounding box and midpoint.
- Xlsx to CSV: convert excel sheet to csv.
- Xlsx to markdown: convert excel workbook to markdown.
- Har summarize: Summarize a HAR 1.2 JSON log into deterministic request, status, MIME, host, timing, size, and redaction counts.
- Hebrew civil date convert: Convert dates between proleptic Gregorian calendar and civil Hebrew calendar
- Rtf inspect: Inspect an 8 KiB ANSI-1252 RTF text subset: paragraphs, omitted destinations, pictures, objects and warnings.