Analytic geometry.

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).
Comments
54
It doesn't, it's left to the triangle. If you need the solution, pm me, but I want sexual pleasures for helping you!
can you prove it mathematically?
Parent
Make a translation of the system in the point (5,4). After that I guess that if the sum of the angles between the vectors unifying the points and the origin is 360 you have an interior point (this is just a guess... ).
Parent
check my post :)
Parent
thx for links, but i'm kinda surprised about the first page where the formula is based on scalar multiplication, but it's never mentioned there.. Well programmers don't care much about math anyway, so I guess it's understandable. =D Anyway see my last posted link, it's there a as well, the same "u" and "v" parameters.
Parent
q3 zadrot
i just came from my vacation

dont know this stuff anymore :(
are u in elementary school?
her's graf

image: 2vuc08y

proving it's not on the triangle is pretty easy i think, thinking of a way to prove it's not inside the triangle
Quoteproving 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?
Parent
im assuming you mean "it's not hard", although

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
Parent
if it lied within the triangle it wouldn't necessarily be on the line anyway?
Parent
which is why I said I didn't think of a method to prove it's within the triangle yet ;d
Parent
damn your 20, why cant you solve that one?
Parent
i can solve it, but my techniques doesn't satisfy me.
Parent
oh, good luck improving then :)
Parent
http://en.wikipedia.org/wiki/Point_in_polygon
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).
Parent
see dunno, "ask perfo" isnt always wrong
Parent
nice paint skills :D
Parent
check your nickname
here my solution:

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.
Yeah I thought about taking every possible pair of points from the triangle and compare angles considering third point, but i'm sure you can do it other way.
Parent
the lowest line (2,1) to (9,10) has the equation y = x + 1

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
there is no term "the lowest" line, so I can't apply it in solving the problems :(
Parent
well, do what i did for all the lines, and prove it's below all of them, i'm just too lazy so i made it quick for myself ^-^
Parent
it's not really like that. you can have a point that technically can be below 2 lines, but above another one.
Parent
this one is below all of them, proving it CANT be in the triangle... if it was in the triangle then it would be above only 2 or below only 2.
Parent
simple solution:
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).
i have a better solution, wait
Parent
i think i should apply vector multiplication from radius-vectors there and this can work out. Since your solution will not work out if the point is behind the triangle in relation to (0,0)
Parent
just to be sure about this; you DO realise my solution works for any point and any triangle? the only one here so far that does?
Parent
actually ur solution doesnt work for the point, which could be behind the triangle.
My first solution is actually the same what u have
Parent
I do realise this, but for a minute imagine a more complex figure created with 10 points. What are you going to do now? =D The algorithmic complexity of your solution is around O ( N^3 ) where N is amount of sides of the figure. That's quite high, but possible to apply for easy problems.
Parent
my 2nd solution can be used for more difficult cases as I said before,
u use the same princip, so whats problem? :)
Parent
yeah but in this task u have the point not behind, or u want the generally solution for all possibilities beside ur task?
Parent
see my 2nd solution, its more generally solution.

The overall general solution is easy too, just compare the areas of triangles if u consider ur point inside of the triangle, or outside
Parent
won't work :)
Parent
it will lol, the princip, the idea will work

im off here
Parent
there is a possibility that area of the every possible triangular where one of the point is 4th will be lower than the original triangular. Want an example?
Parent
no, but u can split it on another way, for example build a parallelogramm of ur first triangle, after the one which has ur 4th point. Just make the triangles smaller, and it works.

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.
Parent
it actually exists, when I figure that out I will inform you. You are going the wrong way imo. Angle way is closer to the general solution.
Parent
yeah of course, even if this exist, then in the general case u should show, that for ur point, if this is outside the set, exist a small e>0, so that for all real numbers in the e-area they all ar outside the set.
hf constracting the general case
Parent
so? its not a general case which we were talking about.
Its just for triangles
Parent
better solution:
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)
Parent
it could be another triangle with its third point outside the initial triangle and still having a smaller area
Parent
It's easy as shit,saw it probalby on my 14 years already but it has been such a long time already that i don't know much about that stuff anymore.
You just need to prove the following (well i hope so, its been a while since i did this. 2nd year uni maths and i'm not 100 percent on simple geometry >.<)



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.
I started describing the method, but then deleted everything coz i realized someone else must have described it better before me. And I was right.

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!
Back to top