# Analytic geometry - triangle [closed]

I have three points: A[1, 2]; B[3, 5] and C[5, 7]

I have some random points, like this: E [4, 4] etc.

I need to check if these random point are a part of the ABC triangle, or not.

## closed as off-topic by Carl Woll, Daniel Lichtblau, LCarvalho, Henrik Schumacher, MarcoBJun 20 at 6:01

• The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

Use RegionMember:

rmf = RegionMember@Triangle[{{1,2},{3,5},{5,7}}];

Random points:

pts = RandomReal[7, {10^3, 2}];

Use the RegionMember function to find out which points are a part of the triangle:

Tally[rmf @ pts]

{{False, 972}, {True, 28}}

Visualization:

Graphics[{
Red, Point[Pick[pts, rmf@pts, False]],
Blue, Point[Pick[pts, rmf@pts, True]],
Black, RegionBoundary@Triangle[{{1,2},{3,5},{5,7}}]
}]

Sounds like you should ask this question on the Math StackExchange site. To get the relevant equations using Mathematica you could do:

RegionMember[Triangle[{{1,2},{3,5},{5,7}}], {x, y}]

(x | y) ∈ Reals && -(5/2) (-1 + x) + 2 (-2 + y) >= 0 && 2 + 3/2 (-1 + x) - y >= 0 && 3 - x + 2 (-2 + y) - y <= 1

• In which language is this code written? – Cséfalvay Bálint Jun 11 at 19:41
• @CséfalvayBálint It is written in Mathematica of course. What do you expect on the Mathematica StackExchange site? – Carl Woll Jun 11 at 19:42
• Then I chose a wrong side, because I need mathematical equation, or something like that. – Cséfalvay Bálint Jun 11 at 19:52