Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / checking within three 2d coords

Author
Message
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 13th Jun 2011 03:51 Edited at: 13th Jun 2011 04:16
I'm getting a three coordinates to form a triangle.



I want to check to see if a fourth coordinate is within the triangle of the three coordinates.

Attachments

Login to view attachments
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 13th Jun 2011 10:35
It's not easy math, but if you write "point inside triangle" or "point within triangle" into a search engine, you'll get some good articles about it. For example:

http://www.mochima.com/articles/cuj_geometry_article/cuj_geometry_article.html

http://www.blackpawn.com/texts/pointinpoly/default.html
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 15th Jun 2011 13:33 Edited at: 15th Jun 2011 13:37
Ya I think i got it on my own, its all about angles you see muah ha ha ha..

lets imagine a function call:

bool halfgraph( compressed int, compressed int, compressed int);
its job was to take in (a position, a rotation, and a position).

it then would spit out right or left.

based on that information the program could then check a position against a (position,rotation)

[edit]time 3:33

so with this you can take the three locations, get angles between them, then use the angles for "halfgraph". Checking your "forth" cordinate against your three triangle (positions and rotations)

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-10-02 17:27:30
Your offset time is: 2024-10-02 17:27:30