☖ Home Units Converter Geometry Σ Math Physics Electricity

Find if a point is inside or outside of a triangle

Print triangle point in/out
Triangle vertex coordinates Triangle lines equations Test point
x1 y1 y = x + px py
x2 y2 y = x +
x3 y3 y = x +
Point location:

Find if a point is inside or outside of a circle

Print circle point in/out
Circle equation: ( x - )2 + ( y - )2 =
x2 + y2 + x + y + = 0
Test point (x ,y): ( , )
Point location:

Find if a point is inside or outside of a triangle summary

Print triangle point in/out
Determine if a point is inside or outside of a triangle whose vertices are the points
(x1, y1), (x2, y2) and (x3, y3).
By vectors analysis - if the cross product of the vectors:
are all positive or all negative, the point is inside the triangle.
The cross product of all three pairs of the triangle sides are:
After solving the determinants we get the values:
k1 = (px ⎯ x1)•(y2 ⎯ y1) ⎯ (py ⎯ y1)•(x2 ⎯ x1)
k2 = (px ⎯ x2)•(y3 ⎯ y2) ⎯ (py ⎯ y2)•(x3 ⎯ x2)
k3 = (px ⎯ x3)•(y1 ⎯ y3) ⎯ (py ⎯ y3)•(x1 ⎯ x3)
If all three equations are either positive or negative then the point (px, py) is inside the triangle.
If triangle is given by the lines equations:
y = m1x + b1
y = m2x + b2
y = m3x + b3
Find intersection points of the sides of the triangle.
After finding the intersection points use the vector method.
Example: given a triangle whose vertices are at (3, ⎯ 2), (1, 5) and (⎯ 3, 2) determine if the point (1, 3) is inside or outside of the triangle. Find k1, k2 and k3.
k1 = (1 ⎯ 3)•(5 ⧾ 2) ⎯ (3 ⧾ 2)•(1 ⎯ 3) = ⎯ 4
k2 = (1 ⎯ 1)•(2 ⎯ 5) ⎯ (3 ⎯ 5)•(⎯ 3 ⎯ 1) = ⎯ 8
k3 = (1 ⧾ 3)•(⎯ 2 ⎯ 2) ⎯ (3 ⎯ 2)•(3 ⧾ 3) = ⎯ 22
Because the signs of k1, k2 and k3 are all negative the point is inside the given triangle.
The vector analysis can be applied to any convex polygon that has n sides to determine if the point p is inside the polygon.
k1 = (px ⎯ x1)•(y2 ⎯ y1) ⎯ (py ⎯ y1)•(x2 ⎯ x1)
···
kn-1 = (px ⎯ xn-1)•(yn ⎯ yn-1) ⎯ (py ⎯ yn-1)•(xn ⎯ xn-1)
···
kn = (px ⎯ xn)•(y1 ⎯ yn) ⎯ (py ⎯ yn)•(x1 ⎯ xn)
This calculation should apply to each side of the polygon from 1 to n. If the signs of all k's are the same positive or negative then the point p is inside the polygon.
Note: this method applies only to convex polygons.

Find if a point is inside or outside of a circle summary

Print triangle point in/out
How to determine if a point (px, py) is inside or outside of a circle given by the form
(x ⎯ a)2 ⧾ (y ⎯ b)2 = r2
The center of the circle is at point: (a, b)
The radius of the circle is: r
Find the distance of point (px, py) from the center of the circle by
the equation:
If the distance is less then the radius then the point is inside the circle.
If the circle equation is of the form
x2 ⧾ y2 ⧾ Ax ⧾ By ⧾ C = 0
The center of the circle is at point:
The radius of the circle is:
Find the distance of point (px, py) from the center of the circle
by the equation:
If the distance is less then the radius then the point is inside the circle.