to check wether the give point is inside a ploygon

Hi all ,

I want to implement a draggable polygon in java I was able to Implement for a line and for a box . For a polygon the set of values we take are not constant and the shape is also irregular to deside too .

Can any one send me java code or snippet how to implement it .

Thanks in advance

raghavan

[336 byte] By [raghavan_26a] at [2007-11-27 7:49:59]
# 1
Polygon p = ...if (p.contains(x, y)) {...}Source code of the contains method is in the src.zip file.
rkippena at 2007-7-12 19:30:58 > top of Java-index,Security,Cryptography...
# 2

Just for fun, I was thinking about an algorithm to do this. Here's what I came up with... I think it's the right answer but you tell me

Basically, in a polygon, you have n vertices and n - 1 sides. Since the sides actually define the polygon, all you need to do is find out what side of each of the sides the point lies on, and make sure that its on the inside side for each chord.

Is this correct?

tjacobs01a at 2007-7-12 19:30:58 > top of Java-index,Security,Cryptography...
# 3
Actually my previous solution won't always work on non-regular polygons. hmm...
tjacobs01a at 2007-7-12 19:30:58 > top of Java-index,Security,Cryptography...
# 4
hi where can I find that src code of that class man ?thanks in advanceraghavan
raghavan_26a at 2007-7-12 19:30:58 > top of Java-index,Security,Cryptography...
# 5

Search your computer for src.zip, here's a tip:

It will be in the Java installation folder.

Don't ask me why they put it there, they were probably just trying to be clever.

So, don't worry if you couldn't figure out where it would be, because it's obviously not in an obvious spot.

rkippena at 2007-7-12 19:30:58 > top of Java-index,Security,Cryptography...
# 6
haii thanks a lot rkippensorry for that post I got the sorce code allready for got to say that .....Thanks a lot for Ur kind help
raghavan_26a at 2007-7-12 19:30:58 > top of Java-index,Security,Cryptography...