PDA

Click to See Complete Forum and Search --> : Help needed: collisiondetection in 2d


essohbee
Dec 25th, 2000, 04:22 PM
Okay, here's the deal:
I have a threesided polygon, aka a triangle,
vertices are defined as following

For i = 0 To 2
Line1(i).X1 = Sin((v + (120 * i)) / 57) * 200 + ox
Line1(i).Y1 = Cos((v + (120 * i)) / 57) * -200 + oy
Line1(i).X2 = Sin((v + (120 * (i + 1))) / 57) * 200 + ox
Line1(i).Y2 = Cos((v + (120 * (i + 1))) / 57) * -200 + oy
Next i

Whereas ox and oy as offset variables
as to where the triangles'centrum in
the void is.

Problem being: I need a routine
(algorithm, whatever) to find out
if the point p (p.x, p.y) is inside
the triangle.

Any help would be greatly appreciated.

Jotaf98
Dec 26th, 2000, 09:54 AM
Sorry, can't help you.

But I have a similar problem: for a 3d engine I'm making (not from a tutorial or something, I'm doing it ON MY OWN so I'm having lots of problems), I'd like to have a fast way of detecting if a dot is inside a triangle or rectangle if possible... sort of I give the function the X, Y and Z coordinates of each point of the triangle, and the X, Y and Z coordinates of the point, and it would return True if it was inside it...

Jotaf98
Dec 26th, 2000, 09:57 AM
And could you please elaborate a bit more on that function, maybe give me a working example of what it does, because I don't know much on trigonometry...

Dec 27th, 2000, 09:30 AM
My site shows how to detect if an object is within a box.
The site is http://www.gamecreator.cjb.net. That site shows how to detect a box collision. Go into collision detection.
Hope it helps :-)
Dan

essohbee
Dec 27th, 2000, 03:10 PM
Uhm.. what you're describing is boundingbox-detection, which is a bit to rough to use unless you divide the
object into several parts.