Unexpected true/false result of contains method of Polygon
Dear All,
I have a really simple problem with polygon. For demo purpose, I check if a vertex of polygon is contained by this polygon. Normally this should be all true, but some of them is false.
Here is my sample program:
import java.awt.Polygon;
publicclass PolygonEx
{
publicstaticvoid main(String[] args){
Polygon p =new Polygon();
p.addPoint(196,156);
p.addPoint(208,164);
p.addPoint(216,182);
p.addPoint(198,200);
p.addPoint(175,182);
p.addPoint(185,158);
p.addPoint(196,156);
for (int p_cnt = 0; p_cnt < p.npoints; p_cnt++)
{
int tp_x = p.xpoints[p_cnt];
int tp_y = p.ypoints[p_cnt];
System.out.println("P:"+p_cnt+" x:"+p.xpoints[p_cnt]+" y:"+p.ypoints[p_cnt]+" IsContained:"+p.contains(tp_x, tp_y));
}
}
}
and, output:
P:0 x:196 y:156 IsContained:false
P:1 x:208 y:164 IsContained:false
P:2 x:216 y:182 IsContained:false
P:3 x:198 y:200 IsContained:false
P:4 x:175 y:182 IsContained:true
P:5 x:185 y:158 IsContained:true
P:6 x:196 y:156 IsContained:false
Is this a bug, or I miss sth ?
Regards,

