Analytic geometry.
•
7 Jan 2009, 23:47
•
Journals
Given 3 points of the triangle:
(1,2)
(4,6)
(9,10)
Determine if point (5,4) belongs to triangle (is located inside the triangle).
(1,2)
(4,6)
(9,10)
Determine if point (5,4) belongs to triangle (is located inside the triangle).
dont know this stuff anymore :(
proving it's not on the triangle is pretty easy i think, thinking of a way to prove it's not inside the triangle
if it's not hard then how?
A (1,2)
B (4,6)
C (9,10)
formula of line AB -> y = 4/3x + 2/3
formula of line BC -> y = 4/5x + 2.8
formula of line AC -> y = x + 1
filling in X (5,4) in all cases:
4 = 4/3x5 + 2/3
4 != 22/3
4 = 4/5x5 + 2.8
4 != 6.8
4 = 5 + 1
4 != 6
meaning point X isn't on any line of the triangle
but i don't know if that's what you're looking for :D
Going both ways (-'ve and +'ve) horizontally gives you an even amount of intersections (0 and 2), so it's not in the polygon (triangle).
u have to get from every point to another point the angle, which they build together to x-axis. if the 4th point is in trinagle, so he must always be between angles and never outside.
if x = 5 then y must be greater than 6 for it to lie above this line and therefore in the triangle,
i guess that works ;x
build the straight line form (0,0) to every of 4 points.
all 3 lines, which go through ur triangle points, ar above the line, which goes through ur point (5,4).
My first solution is actually the same what u have
u use the same princip, so whats problem? :)
The overall general solution is easy too, just compare the areas of triangles if u consider ur point inside of the triangle, or outside
im off here
U should understand, there is no general solution for a general case. A triangle is nothing else as a set of points. The set u can determine ur own way, there exist more difficult sets as u even thinks, thats why the general case for all sets doesnt exist.
All u should do, is just consider ur case in ur task.
hf constracting the general case
Its just for triangles
1. find the area of ur triangle.
2. Now take the points: (5,4), (4,6), (9,10) and build the second triangle.
If ur point (5,4) is in the triangle of the 3 points (1,2), (4,6), (9.10), so the area of the second triangle should be lower as the first one. But its not so. So we get the contradiction, that means, our point is outside.
If u have problems to find the area of triangles, just use the determinant of 2 Vektors after switching ur triangle to (0,0)
Given 3 points of the triangle:
(1,2)
(4,6)
(9,10)
Determine if point (5,4) belongs to triangle (is located inside the triangle).
so you have lines:
(1,2)->(4,6)
(4,6)->(9,10)
(1,2)->(9,10)
you need all 3 of the following to hold true for point (5,4)
y <= 4/3x + 2/3 (true)
y >= x + 1 (false)
y <= 4/5x + 14/5 (false)
:. (5,4) does not lie inside the triangle.
QED
p.s. when you say points of a triangle I'm sure you mean vertices.
http://www.blackpawn.com/texts/pointinpoly/default.html
There's also a book that covers it and other stuff like that :)
http://realtimecollisiondetection.net/books/rtcd/toc/
Have fun!