# [JAVA2D] Finding intersection points

I have two queries. The first is, I want to be able to draw lines

connecting circles, but I can't seem to find the point of intersection

between the lines and circles. I want to have the lines begin at the

point of intersection of the circle, that is, not have any trace of the

line inside the circle. I have tried using intersecting areas, but I

don't think this idea works with lines and shapes. I also tried using

composite rules (DstOver, SrcOut) but the lines don't appear when drawn.

Right now the lines are being drawn from the center of the circles,

which poses my next query. This one is a bit complicated.

I have tried and tried to see how to do this, but to no avail. As I

said, I currently have lines drawn from one center of a circle to

another. The desired outcome is to be able to have two lines drawn from

one circle to another, with a given offset from the line connecting the

centers. Well I have tried to use geometric equations to find out how to

calculate the points of the other lines, but the constraint of having it

worked for any sloped line is giving me troubles.

Thanks in advance,

Walter Shirey

===========================================================================

To unsubscribe, send email to listserv@java.sun.com and include in the body

of the message "signoff JAVA2D-INTEREST". For general help, send email to

listserv@java.sun.com and include in the body of the message "help".

[att1.html]

Yes, thank you for this information. Let me ask you this: how do you

determine the intersection of a line starting inside a circle and that

circle without knowing the distance from the end of the line to the

point on the circle? What I want to do is to be able to have two lines

connecting the circle, offset a given distance from this center line,

without regard to the angle.

Walter Shirey

-----Original Message-----

From: Bill Casselman [mailto:cass@math.ubc.ca]

Sent: Sat 1/24/2004 10:38 PM

To: Walter H Shirey

Cc: david@merganser.math.gvsu.edu; cass@math.ubc.ca

Subject: Re: [JAVA2D] Finding intersection points

One of the most useful simple calculations in

all of graphics is a point interpolation function.

It has two points P = (xP, yP) and Q = (xQ, yQ)

and a real number generally between 0 and 1 as arguments,

and returns the weighted average

(1-t)P + tQ = ( (1-t)*xP + t*xQ, (1-t)*yP + t*yQ )

which lies t of the way from P to Q.

Thus if t = 1/2 this average lies halfway between the two

points.

In your case you apply it twice, both with P = first center,

Q = second center; t = R/D for the starting point of your line;

t = (D-R)/D for its end. Where D = distance from P to

Q, or D = sqrt((xQ-xP)*(xQ-xP) + (yQ-yP)*(yQ-yP)).

Helps?

===========================================================================

To unsubscribe, send email to listserv@java.sun.com and include in the body

of the message "signoff JAVA2D-INTEREST". For general help, send email to

listserv@java.sun.com and include in the body of the message "help".

[att1.html]