# RE: printing three display components

```Thanks Bill for your reply.

However, I currently only using Java-2D to generate graph (2D, planning
to make into 3D after getting 2D done). I was trying to look for the
algorithm, on how to detect a LINE if it is in a POLYGON, where the
LINE's end and start points are given, and the POLYGON Area is obtained.
The polygon is a tilted rectangle or a tilted pentagon. The angle of the
tilted polygon is the same as the line.

I know this is really unrelated to VisAD. But I do hope if anyone of you
did come across any articles or resources on this matter please kindly
point me to it or guide me.

Thank you.
Kj

Ps: Bill, even with the methods you mentioned, it can only detects a
point. If this is the case, that means I need to run trough a loop for
every point in the line in order for me to know if any part of the line
is in a specified polygon. The problem is that I might need to check for
hundreds or even thousands of lines (performance issue). Hence, I was
looking for if there is any geometric or algorithm that can really save
all of this looping, you know, by using some formula. Thanks.

-----Original Message-----
From: Bill Hibbard [mailto:billh@xxxxxxxxxxxxx]
Sent: Friday, July 25, 2003 5:35 PM
To: Tan Ka Ju
Subject: RE: printing three display components

If you are using VisAD, then the method:

public static boolean inside(float[][] s, float x, float y)

in visad.DelaunayCustom will tell you if the point (x, y)
is inside the polygon described by s, which is dimensioned
float[2][number_of_points].

On Fri, 25 Jul 2003, Tan Ka Ju wrote:

> Hello.
>
> Is their in Java any method to know is a line contains or inside an
> arbitrary polygon or shape? Or is the any algorithm or mathematics
> formula that can solve this problem?
>
> Thanks.
> KJ

```