Hi,

These methods are not implemented in Java standard API.

I give you the line intersection routine :

public static Point2D lineIntersection(Line2D line1, Line2D line2)
{ Point2D cp = null;
        double a1,b1,c1,a2,b2,c2,denom;
        a1 = line1.getY2()-line1.getY1();
        b1 = line1.getX1()-line1.getX2();
c1 = line1.getX2()*line1.getY1()-line1.getX1()*line1.getY2(); // a1x + b1y + c1 = 0 line1 eq
        a2 = line2.getY2()-line2.getY1();
        b2 = line2.getX1()-line2.getX2();
c2 = line2.getX2()*line2.getY1()-line2.getX1()*line2.getY2(); // a2x + b2y + c2 = 0 line2 eq
        denom = a1*b2 - a2*b1;
        if(denom != 0)
cp = new Point2D.Double((b1*c2 - b2*c1)/denom,(a2*c1 - a1*c2)/denom);
        else
        {
            // lines are parallel
        }
        return cp;
}


You should read the state of the art books on Computational Geomatry to find this kind of algorithms.


Jérôme Thièvre


[EMAIL PROTECTED] a écrit :
Hi all,

It seems that the intersct() of Line2D will only return a boolean value. I'm 
looking for some sample code to calculate the intersection of a line and a 
polygon (or 2 lines) and return the point. In addition, I need to calculate the 
area of a regular polygon. I guess the the source files of Line2D.intersect() 
and Graphics2D.fill() will help a lot. I'll look into those files later in the 
afternoon. But I hope I can get some suggestions from you. Thank you in advance.
[Message sent by forum member 'lcmeng' (lcmeng)]

http://forums.java.net/jive/thread.jspa?messageID=254428

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
begin:vcard
fn;quoted-printable:J=C3=A9r=C3=B4me Thi=C3=A8vre
n;quoted-printable;quoted-printable:Thi=C3=A8vre;J=C3=A9r=C3=B4me
org;quoted-printable:Institut National de l'Audiovisuel;Direction Recherche et Exp=C3=A9rimentations
email;internet:[EMAIL PROTECTED]
x-mozilla-html:TRUE
version:2.1
end:vcard

Reply via email to