Advertisement

Finding a point within a triangle...?

Started by June 01, 2001 12:20 AM
1 comment, last by duckbob 23 years, 8 months ago
Ok, I''ve got a really simple question. I have four points (x,y), three form the verticies of a triangle and a forth is the location of a "player" How can i find if the forth point lies within the triangle formed by the first three? Duckbob
Know the winding of the triangle segments (counter-clockwise or clockwise) to begin with. In a clockwise winding, if the point is to the left of any of the segments, it is outside. If it survives all three tests, that is, it is NOT to the left, then the point is inside.

If the signed area * 2 of the triangle defined by the line segment A - B and the point P is > 0.0, then P is to the left of the line segment A - B. Pass the args in as P, A, B.

    #define tri2sgnarea2(a,b,c) (	( ( (b)[0] - (a)[0] ) * 	  ( (c)[1] - (a)[1] ) - 	  ( (c)[0] - (a)[0] ) * 	  ( (b)[1] - (a)[1] ) ) )    




Edited by - bishop_pass on June 1, 2001 2:58:29 AM
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
Advertisement
It mangled my macro. I do not understand why it would do something so inept as that. It''s supposed to render source code, which means don''t do anything to the text, but it has to go and do crap to it.

Unbelievable.




_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.

This topic is closed to new replies.

Advertisement