Finding endpoints of line segment inside circle

Chrome

New member
Joined
Jun 27, 2008
Messages
5
Ran into the following problem while working on a program, and for some reason just can't figure how to solve it; seems awfully familiar from my math days, but it's been too long since then. ?, r, and y are all known, and the circle can be assumed to be centered at the origin. Need to find the co-ords of both endpoints of line segment y. Any assistance would be greatly appreciated.

 
It is unfortunate that you have used 'y' for the semi-secant segment. I'll just play like that didn't happen.

The equation of the circle, with the new y-definition as the name of a coordiante axis is \(\displaystyle x^{2} + y^{2} = r^{2}\). That's simple enough.

The equation of the line containing the secant segment is \(\displaystyle x\cos(\theta)\;+\;y\sin(\theta)\;-\;p\;=\;0\). The Normal Form is a good one to know.

From the Pythagorean Theorem, we have \(\displaystyle p^{2}+y^{2}=r^{2}\). In this case, I used your \(\displaystyle ``y\mbox{"}\) as you have labled it.

That's about it.
 
I tried following your logic, but the misformated middle formula makes that extremely hard, especially since I'm not sure where the P variable came from. Might as well change y in the picture to S, for ease of notation. Discovered that the line segment is also called a Chord, and using a formula I found for that: sqrt(2-2Cos(D))=S, where D is the angle from endpoint1-origin-endpoint2. This gives D=cosh((S^2-2)/-2). This would make the angle to the two endpoints ?+D/2 and ?-D/2, and the co-ords of the two points at (rcos(?+D/2),rsin(?+D/2)) and (rcos(?-D/2),rsin(?-D/2)), correct? Doesn't seem to be working, though I am looking for other errors that could be the source of the problem (non-math errors). Thanks for the attempt at help though, and would love further input.
 
I defined p for you in the third formula. Draw the radius to an end of the chord. You have a right triangle and the missing leg is length p. It is the minimum distance from the center of the circle to the chord.

The three equations can be solved algebraically and the coordinates of the two points determined.

You may, if you wish, use the central angle created by drawing he radius to the end fo the chord, to find the location more as you have described. Clearly, \(\displaystyle \sin(D/2)\;=\;s/r\)

Your expressions with D/2 seem fine. You should be able to expand and simplify, then apply a little algebra and get something nice like this:

\(\displaystyle (p*\cos(\theta})-s*\sin(\theta),p*\cos(\theta})-s*\sin(\theta))\)

Or, with a little more effort:

\(\displaystyle \left(r*\sin\left(\theta+atan\left(\frac{p}{s}\right)\right),r*\sin\left(\theta-atan\left(\frac{s}{p}\right)\right)\)
 
Thank you tkhunny! Updated my formula to find D with what you provided (\(\displaystyle D=2*asin(\frac{S}{r})\)), and it is working like a charm! Took awhile to realize this due to what turned out to be rounding errors, unfortunately, and your final two expressions weren't posted yet for me to take advantage of them. Thank you again.
 
Mmm, don't see how there's an issue at 90º. I'm using the two formulas: \(\displaystyle D=2asin(\frac{S}{2r})\) and \(\displaystyle (rcos(\theta\pm\frac{D}{2}),rsin(\theta\pm\frac{D}{2}))\). D cannot be greater than 180º clearly, since at that point the line segment is longer than the diameter of the circle; is this the issue you're mentioning? Some confusion could arise since I notice I forgot to divide S by 2 in the previous formula (since we're using half of S to find half of D). I hadn't actually thought of that problem yet, but now that you mention it it would be a good idea to limit \(\displaystyle S\leq2r\)
 
By definition \(\displaystyle -\frac{\pi}{2}\;\leq\;asin(x)\;\leq\;\frac{\pi}{2}\).
 
Right, so \(\displaystyle asin(x)\le90^o\), but since \(\displaystyle D=2*asin(x)\), \(\displaystyle D\le180^o\). Same issue, we're just thinking of D in slightly different terms I believe. :)
 
Top