Point in triangle checker
The point (1, 1) lies inside the triangle with corners (0, 0), (4, 0) and (0, 3), whose area is 6. Enter a point and three corners to learn whether it is inside or outside, for hit tests, mesh samples or homework. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- X
- 1
- Y
- 1
- X1
- 0
- Y1
- 0
- X2
- 4
- Y2
- 0
- Area
- 6
Deciding whether a planar point sits inside a triangle is a core primitive of computational geometry. Students verifying homework, game engines hitting hitboxes, GIS tools classifying samples against triangular meshes, and CAD pipelines validating seeds all need a fast, deterministic answer rather than a hand sketch. This point in triangle checker accepts the query coordinates and the three vertex pairs, builds barycentric weights from signed sub-triangle areas, and reports inside (including the boundary) or outside. Non-numeric or missing coordinates also fail and are not billed.
What point-in-triangle means and how barycentric weights decide it
A triangle in the plane is the convex hull of three non-collinear vertices A, B, and C. A query point P lies inside that triangle when it can be written as a convex combination of the three vertices: P equals a·A plus b·B plus c·C with a, b, and c non-negative and a plus b plus c equal to one. Those weights a, b, and c are the barycentric coordinates of P with respect to ABC.
Algebraically they equal the ratios of signed areas of the three sub-triangles PBC, PCA, and PAB to the signed area of ABC itself. Twice the signed area of any triple is the familiar shoelace cross product, so the whole test is a handful of multiplications and additions with a single division by the triangle area. When all three weights are greater than or equal to zero, P is inside or on the boundary; when any weight is strictly negative, P lies on the outside of the opposite edge.
Clockwise and counter-clockwise vertex orders are both accepted: the signed area may flip sign, but the barycentric ratios stay consistent and the containment decision does not. This approach avoids slope comparisons that break on vertical edges and avoids ray casting noise that is better reserved for general polygons with many sides.
Where a point-in-triangle checker earns its keep
Classroom and tutoring platforms use a point in triangle checker so learners can verify homework triples without drawing and without slope arithmetic that fails on vertical sides. Exam and LMS auto-graders need a deterministic oracle that marks inside versus outside consistently, treats boundary points as inside, and rejects degenerate collinear vertices instead of silently returning false. Game and simulation code hit-tests triangular collision primitives against player or projectile samples without pulling a full physics middleware package for a single triangle.
GIS and meshing pipelines classify sample points against Delaunay or finite-element triangles before interpolating attributes. Failed validation is not billed. Keep requests small, pin the rounded barycentric weights and area in tests, and you get reproducible containment answers for homework, edge workers, and CI without standing up a geometry library of your own.
For general n-gons use a sibling polygon containment tool; this page exists for the triangle-specific search intent.
What you can do with it
Classroom and homework checks
Let students submit a query point and three vertices and verify whether the point lies inside the triangle without hand sketches or fragile slope tests.
Exam and LMS auto-grading
Mark point-in-triangle items with a deterministic oracle that rejects degenerate collinear vertices and treats boundary points as inside.
FAQ
How do I check if a point is inside a triangle?
Send finite numbers x,y for the query and x1,y1,x2,y2,x3,y3 for the three vertices.
What if the triangle is degenerate?
Point-in-triangle is undefined for a line segment; those failures are not billed.
Does vertex order matter (clockwise vs counter-clockwise)?
No. Both orientations work. Signed areas flip sign together, so the barycentric ratios and the inside decision stay consistent.
Is a point on an edge or corner counted as inside?
Yes. A point exactly on an edge or a corner counts as inside and is flagged as lying on the boundary, the usual convention for closed triangles in homework keys and mesh queries.
What do the three weights in the result mean?
They are the barycentric weights of the point, one per corner, and they always add up to 1. All three at zero or above means inside; any negative weight means the point lies beyond the opposite edge.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geom/point-in-triangle \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x":1,"y":1,"x1":0,"y1":0,"x2":4,"y2":0,"x3":0,"y3":3}'const res = await fetch("https://api.kit.forhosting.com/geom/point-in-triangle", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x": 1,
"y": 1,
"x1": 0,
"y1": 0,
"x2": 4,
"y2": 0,
"x3": 0,
"y3": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/point-in-triangle",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x": 1,
"y": 1,
"x1": 0,
"y1": 0,
"x2": 4,
"y2": 0,
"x3": 0,
"y3": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/point-in-triangle", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x":1,"y":1,"x1":0,"y1":0,"x2":4,"y2":0,"x3":0,"y3":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x":1,"y":1,"x1":0,"y1":0,"x2":4,"y2":0,"x3":0,"y3":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/point-in-triangle", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"x": 1,
"y": 1,
"x1": 0,
"y1": 0,
"x2": 4,
"y2": 0,
"x3": 0,
"y3": 3
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.point_in_triangle",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Degenerate triangles whose vertices are collinear have zero area and fail with invalid_input instead of a hollow guess.
What point-in-triangle means and how barycentric weights decide it
Points that land exactly on a vertex or edge produce a zero weight and are reported as inside with on_boundary true, matching the usual closed-triangle convention used in mesh queries and homework keys.
Input contract, response shape, and error behaviour
Example: vertices (0,0), (4,0), and (0,3) with query (1,1) yield inside true because all barycentric weights are positive and the triangle area is six. The same triangle with query (5,5) yields inside false because at least one weight is negative. Pair the response with your own plot if you need a sketch; this capability only classifies containment and does not emit SVG, winding numbers for general polygons, or step-by-step classroom prose beyond the numeric fields. POST a JSON body with eight required finite numbers: x and y for the query point, then x1 and y1 for vertex A, x2 and y2 for vertex B, and x3 and y3 for vertex C. Each field may arrive as a JSON number or as a numeric string; missing fields, empty strings, NaN, Infinity, and non-numeric text fail with invalid_input naming the field, and those failures do not consume balance. On success the body includes the boolean inside, the boolean on_boundary, the echoed eight coordinates rounded for stable goldens, the positive triangle area, a barycentric object with weights a, b, and c rounded to twelve decimal places, and method set to barycentric so clients can document the algorithm next to the answer.
Integration use cases
Games, GIS, and mesh queries
Hit-test triangular primitives or classify samples against mesh faces with a tiny parse API instead of a full geometry stack.
Technical questions
Are points on the edge counted as inside?
Yes. Boundary points produce a zero barycentric weight and are reported as inside with on_boundary true, matching the closed-triangle convention.
What does the point in triangle checker cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.