Tools for agents: Exact triangle barycentric coordinates

Compute triangle interpolation weights with exact projection coordinates and explicit plane and boundary classification.

Connect with MCP

{
  "mcpServers": {
    "super-agent-tools": {
      "url": "https://app.getsupers.com/sites/agent-barycentric/mcp"
    }
  }
}
Streamable HTTP · No API key · Stateless

Use this URL in any client supporting remote Streamable HTTP MCP. Calls return structured JSON; inputs are processed without persistence.

Call triangle_barycentric

Triangle vertices are ordered A,B,C; weights are [alpha,beta,gamma] and always sum to one. They reconstruct the orthogonal projection onto the infinite triangle plane, including for points off the plane. Negative weights are allowed and indicate a projection outside the closed triangle. Classification is off_plane whenever squared_plane_distance is nonzero; otherwise inside means all weights positive, boundary means all nonnegative with at least one zero, and outside means at least one negative. Vertices count as boundary. point_in_closed_triangle includes edges and requires exact coplanarity; projection_in_closed_triangle tests only the projected point. Inputs are integers or quoted finite decimal/fraction strings; JSON floats and booleans are rejected. Degenerate triangles fail, including collinear or repeated vertices. Empty point lists are allowed. Results use exact rationals with no tolerance. This is not the nearest point on a bounded triangle when the projection lies outside, and it does not clamp weights, infer units or perform perspective-correct interpolation.

Input and output schemas
{
  "name": "triangle_barycentric",
  "title": "Exact triangle barycentric coordinates",
  "description": "Compute exact barycentric weights on the plane of a nondegenerate 3D triangle, projected points and separate plane/triangle membership.",
  "inputSchema": {
    "properties": {
      "points": {
        "items": {
          "maxItems": 3,
          "minItems": 3,
          "prefixItems": [
            {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "string"
                }
              ]
            },
            {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "string"
                }
              ]
            },
            {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "string"
                }
              ]
            }
          ],
          "type": "array"
        },
        "title": "Points",
        "type": "array"
      },
      "triangle": {
        "maxItems": 3,
        "minItems": 3,
        "prefixItems": [
          {
            "maxItems": 3,
            "minItems": 3,
            "prefixItems": [
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            ],
            "type": "array"
          },
          {
            "maxItems": 3,
            "minItems": 3,
            "prefixItems": [
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            ],
            "type": "array"
          },
          {
            "maxItems": 3,
            "minItems": 3,
            "prefixItems": [
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            ],
            "type": "array"
          }
        ],
        "title": "Triangle",
        "type": "array"
      }
    },
    "required": [
      "points",
      "triangle"
    ],
    "title": "triangle_barycentricArguments",
    "type": "object"
  },
  "outputSchema": {
    "additionalProperties": true,
    "title": "triangle_barycentricDictOutput",
    "type": "object"
  },
  "icons": null,
  "annotations": {
    "title": null,
    "readOnlyHint": true,
    "destructiveHint": false,
    "idempotentHint": true,
    "openWorldHint": false
  },
  "meta": null,
  "execution": null
}

Run the example to see the actual result.

HTTP alternative

POST https://app.getsupers.com/sites/agent-barycentric/call
Content-Type: application/json

{
  "triangle": [
    [
      0,
      0,
      0
    ],
    [
      2,
      0,
      0
    ],
    [
      0,
      2,
      0
    ]
  ],
  "points": [
    [
      "1/2",
      "1/2",
      0
    ],
    [
      1,
      1,
      0
    ],
    [
      1,
      1,
      2
    ],
    [
      3,
      0,
      0
    ]
  ]
}

The HTTP and MCP interfaces execute the same implementation. Validation errors are returned explicitly. See the tool notes above for its supported inputs and behavior.

Barycentric weights, projection and API input shape

Read the explanation

Barycentric coordinates express a point as a weighted combination of three triangle vertices, with weights summing to one. Consider the saved input example triangle: origin, two along the x axis, and two along the y axis, all in the zero z plane. For a point at one half, one half, zero, the weights are one half, one quarter and one quarter. The x coordinate equals two times the second weight and the y coordinate equals two times the third. Bars compare the first and second weights at six hundred pixels per weight unit, spanning three hundred and one hundred fifty pixels. This is an exact mathematical derivation for the illustrated triangle. It is not a newly observed response from the public service. The saved page describes an exact rational coordinate tool, but this local run does not invoke its backend. For the same triangle, point one, one, zero has weights zero, one half and one half, placing it on the edge opposite the origin. Point three, zero, zero has weights minus one half, one and one half, and zero. The negative first weight identifies a point outside the triangle in its plane. Bars compare positive second weights one half and one and one half at two hundred pixels per weight unit: one hundred and three hundred pixels. A zero weight marks the edge in this example; a vertex has two zero weights. These classifications assume a nondegenerate triangle and coplanar points. A degenerate triangle cannot supply a unique two dimensional barycentric representation, so explicit validation behavior matters. The saved form exposes a schema and notes, but its actual error responses require separate service evidence. An off plane point one, one, two projects orthogonally onto one, one, zero for this triangle. Its projected weights are again zero, one half and one half, while squared distance to the plane is four. Compare an illustrative height one with height two: squared distances one and four, shown at seventy pixels per squared unit as seventy and two hundred eighty pixels. Squaring height changes this quantity quadratically, while the projection keeps the planar weights unchanged. The saved schema requires exactly three vertices, each with three coordinates; points likewise have three coordinates with integer or string entries. Its browser form relies on a shared application script and the documented HTTP or MCP service. That shared runtime is unavailable in the copied offline page. This explainer provides the mathematical example and input contract without claiming the form or backend has been exercised.

Exact Barycentric Interpolation & Plane Projection Guide

How does triangle_barycentric project 3D points onto a triangle's plane and determine exact coordinate classifications?

The triangle_barycentric tool calculates exact rational barycentric coordinates (alpha, beta, gamma) summing to 1 by orthogonally projecting query points onto the infinite plane spanned by noncollinear vertices A, B, and C. It computes exact squared plane distance without floating-point drift, categorizing points as inside, boundary, outside, or off_plane.

Points with any nonzero squared_plane_distance receive classification 'off_plane' regardless of whether their planar projection falls inside, on the boundary, or outside the triangle; inspect projection_in_closed_triangle to determine projected containment. Furthermore, orthogonal projection onto the plane does not compute the closest point on the bounded triangle when a projection falls outside its edges.

Try a worked example

Submit the default form inputs: triangle vertices [0,0,0], [2,0,0], [0,2,0] with four query points. Point [1,1,2] orthogonally projects to [1,1,0] on the z=0 plane with squared_plane_distance '4' and weights ['0','1/2','1/2'], receiving classification 'off_plane' while projection_in_closed_triangle evaluates to true. In contrast, point [1,1,0] has squared_plane_distance '0' on the hypotenuse edge, returning classification 'boundary'.

Projection and Exact Rational Linear System

For triangle vertices A, B, and C, edge vectors u = B - A and v = C - A define a Gram matrix denominator (u·u)(v·v) - (u·v)². For query point P with w = P - A, rational weights beta and gamma solve the orthogonal projection equations directly via Cramer's rule, yielding alpha = 1 - beta - gamma.

Because all operations use exact rational arithmetic (fractions.Fraction), collinear or repeated vertices yield a denominator of zero, raising a nondegenerate validation error without any floating-point tolerance approximations.

Classification Priority and Boolean Flags

The tool checks squared plane distance first: if nonzero, classification is set to 'off_plane'. If coplanar (squared distance 0), it classifies points as 'inside' (all weights > 0), 'boundary' (all weights >= 0 with at least one 0), or 'outside' (any weight < 0). Separate boolean flags point_in_closed_triangle and projection_in_closed_triangle decouple planar membership from boundary bounding checks.