BarySlate supports project-based AI review of geometric calculations. Discuss the determinant and signed weights with a compatible model, then inspect its proposed code using vertices and outside points.
A concrete starting point · Exact triangle barycentric coordinates ×
from fractions import Fraction
def barycentric(vertices, point):
vertices, point = tuple(tuple(v) for v in vertices), tuple(point)
if len(vertices) != 3 or any(len(v) != 2 for v in vertices) or len(point) != 2:
raise ValueError("triangle.shape")
if any(type(c) is not int or abs(c) > 10000 for v in vertices + (point,) for c in v):
raise ValueError("coordinate.range")
(x0, y0), (x1, y1), (x2, y2) = vertices
x, y = point
den = (y1-y2)*(x0-x2) + (x2-x1)*(y0-y2)
if den == 0:
raise ValueError("triangle.degenerate")
a = Fraction((y1-y2)*(x-x2) + (x2-x1)*(y-y2), den)
b = Fraction((y2-y0)*(x-x2) + (x0-x2)*(y-y2), den)
return a, b, 1-a-b
✳Compute exact barycentric weights from three integer vertices and an integer point with coordinate magnitudes at most 10000.
✓ ChangesReview before applying ↗
Illustrative workspace
Project
Test a vertex and an outside point, rejecting collinear vertices and verifying that the weights reconstruct the point.
Review before applying
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
from fractions import Fraction
def barycentric(vertices, point):
vertices, point = tuple(tuple(v) for v in vertices), tuple(point)
if len(vertices) != 3 or any(len(v) != 2 for v in vertices) or len(point) != 2:
raise ValueError("triangle.shape")
if any(type(c) is not int or abs(c) > 10000 for v in vertices + (point,) for c in v):
raise ValueError("coordinate.range")
(x0, y0), (x1, y1), (x2, y2) = vertices
x, y = point
den = (y1-y2)*(x0-x2) + (x2-x1)*(y0-y2)
if den == 0:
raise ValueError("triangle.degenerate")
a = Fraction((y1-y2)*(x-x2) + (x2-x1)*(y-y2), den)
b = Fraction((y2-y0)*(x-x2) + (x0-x2)*(y-y2), den)
return a, b, 1-a-b
AI coding workspace
Turn a geometric requirement into checkable source changes
BarySlate is a Windows coding workspace for discussing geometry-related source with an AI model you connect. Begin with the coordinate system and the result your application needs. A precise description of those conventions helps the conversation stay useful when a visually plausible result could still have the wrong sign, ordering or numeric representation.
The triangle barycentric-coordinate example offers a specific project task: reviewing signed weights and rejecting a degenerate triangle. Ask the model to inspect the function together with the code that consumes those weights. Explain whether the caller needs exact fractions or another representation before requesting a change that might alter that interface.
Review the proposal using vertices, an interior point and an exterior point with independently established expectations. Include a degenerate case and check its route through error handling. Run these fixtures with your project's tools and inspect the consuming behavior as well; changing the treatment of outside points can affect more than the calculation itself.
An unrestricted AI model is a selectable option only when available through your supported OpenAI-compatible or Anthropic endpoint. Provide credentials if required and check context and tool support. The selected model's restrictions still apply, while BarySlate gives its proposed changes a concrete project context in which you can assess them.
Before accepting a geometry-code proposal
What should I say about points outside the triangle?
State whether signed weights are expected and how the caller uses them. Do not assume an exterior point is invalid just because a weight is negative. Include an outside-point fixture with the intended result and consuming behavior.
Why mention exact fractions in the request?
A return-type change can alter comparisons, serialization and downstream calculations. If your project depends on exact values, state that requirement explicitly. Review any proposed conversion to floating-point values together with the callers that would receive them.
Which cases help isolate a coordinate-order mistake?
Start with each vertex and its expected weights, then an interior point with a known result. Keep the vertex order explicit in the fixture. These cases can reveal ordering assumptions that a single rendered triangle may hide.
Can BarySlate confirm my rendered geometry is correct?
Use your rendering environment and project checks to establish that result. The workspace supports code discussion and proposed edits. Compare numerical fixtures with the visible behavior rather than treating either a model explanation or one image as complete verification.