4
418928
Hi everybody,
I have a strange problem. I am defining a polygon and I try to see if
it intersects other rectangular shape. Specifically:
java.awt.Polygon pol = new java.awt.Polygon();
pol.addPoint(1, 0);
pol.addPoint(1, 1);
pol.addPoint(0, 1);
if (pol.intersects(0, 0.9, 0, 0.1))
{
System.out.println("Intersects here!");
}
else
{
System.out.println("Do not intersect here!");
}
And it says: "Do not intersect here!". I'm confused. There should be
an intersection...
I also tried with:
if (pol.intersects(-0.01, 0.09, 0.01, 0.01))
{
System.out.println("Intersects here1!");
}
else
{
System.out.println("Do not intersect here1!");
}
And it says again: "Do not intersect here!".
I'm really confused! I hope you can help me!!
About the context of my problem: I have a polygon P and a rectangle R.
I need to check if R intersects P. If just some points in the boundary
of P match with points of R, that's also an intersection for my
purposes (that's why I enlarge R a little bit -0.01 pixels in each
direction, for example- before calling "intersects"). However, it
doesn't work as expected.
I hope you can give me some idea about why this isn't working and how
to solve it!!
Thanks a lot in advance,
Sergio
I have a strange problem. I am defining a polygon and I try to see if
it intersects other rectangular shape. Specifically:
java.awt.Polygon pol = new java.awt.Polygon();
pol.addPoint(1, 0);
pol.addPoint(1, 1);
pol.addPoint(0, 1);
if (pol.intersects(0, 0.9, 0, 0.1))
{
System.out.println("Intersects here!");
}
else
{
System.out.println("Do not intersect here!");
}
And it says: "Do not intersect here!". I'm confused. There should be
an intersection...
I also tried with:
if (pol.intersects(-0.01, 0.09, 0.01, 0.01))
{
System.out.println("Intersects here1!");
}
else
{
System.out.println("Do not intersect here1!");
}
And it says again: "Do not intersect here!".
I'm really confused! I hope you can help me!!
About the context of my problem: I have a polygon P and a rectangle R.
I need to check if R intersects P. If just some points in the boundary
of P match with points of R, that's also an intersection for my
purposes (that's why I enlarge R a little bit -0.01 pixels in each
direction, for example- before calling "intersects"). However, it
doesn't work as expected.
I hope you can give me some idea about why this isn't working and how
to solve it!!
Thanks a lot in advance,
Sergio