Maths question...
- Started
- Last post
- 20 Responses
- unknown
I have four (X,Y) points on screen... how do i tell if a fifth point is within these four? (assume the four points make a polygon, and don't do that cross over thing)
Any advice would be greatly received, before I delve into Google!
- unknown0
dude?!?
- unknown0
Probably better explained as how does a imagemap work? With a polygon as the rollover shape?!?
- unknown0
dude??!
- providence0
If you can figure out the equation of the polygon.
its usually, something like:
(x1-x2)(x1-y1)=Area of the poly.
if your coordinate solves the equation than it is inside the poly. I think.
look here:
www.mathforum.org/dr.math/faqfaq…...
- unknown0
Tried cutting and pasting that URL, but didn't work :(
- PeterNorf0
Most likely because you do not know how to cut & paste, works fine for me:
- unknown0
It's all very well being a smart arse Peternorf... but look at the page you're brings up... F***WIT
- providence0
Roger Roger
- hahakid0
what do you need to do it in ?
if it's Flash or Director there are probably other ways (hitTest in Flash and something with quads in director I guess)
otherwise there's always the hard way:
- unknown0
Thanks haha... I'm bascially drawing using the API in Flash... so hit test works for everything... I rollover... but doesn't let me distinquish between hich thing I'm rolling on... So I might draw each shape on a different canvas... (Will this slow it all down though!!! :(
- unknown0
Hit test doesn't work reliably with API drawn graphics... Nothing is ever meant to be easy it seems!
- unknown0
... In fact HitTest is the flakiest thing on the planet... I have ten polygons in ten seperate movieclips... when I roll over one of the polygons, it recknos I'm over all of them...AAAHH!!!
- freekilly0
i'm not sure, but if you don't have thousands of polygons, i think it's quicker to name all the MC's containing the polygons, sort them on _level and do a hittest loop that breaks when the first polygon is hit. else it's a bit more complicated. maybe you can figure a way out to split the polygons in two triangles and write a function that tests if the point is within one of them. i'm still thinking on this one.
- freekilly0
by the way, do you store these polygons as an array-object, or xml, or do you only let flash draw the polygon without storing coordinates?
- poopmonkey0
http://www.geog.ubc.ca/courses/k…
might help, i could write the code, but unfortunately i couldnt explain it to you...
- unknown0
Cheers Guys, hooked up with a mate of mine with a maths degree and he's made it super clear...
I tried the multi MC's and hit test... but proves buggy it thinks that if you're on one square you're subsequently over all of them... weird!
- ********0
what are you going to school for this?
- unknown0
Pardon?