"Jürgen" wrote in message <jevnlo$ef$1@newscl01ah.mathworks.com>...
> I have the impression you have understood more of the problem than I explained
> the thing is : I need to find the intersection P(x,y) between a circle and a line. The line goes through the known point (s,t) outside the circle and has a known angle with the radial line through the intersection P(x,y).
> anyway it worked out with the cosinus rule , the only problem that I still have:
> the solution S is still symbolically expressed in function of r, s and t while to make it automatically ( I need to calculate a lot of points) the solution S needs to me a number.
       
Yes, I understood all of that geometry except for your assumption that (s,t) lies outside the circle. In this case you will always get just two solutions (except in the degenerate case of a zero "known angle".) It is with (s,t) inside the circle that you would get four solutions or none.
I suggest that it is a mistake to depend entirely on the 'solve' function to obtain methods of solving problems of this kind. You are looking for 'solve' to give some convenient formula that you can immediately apply efficiently to handle a large collection of parameter values. However, as you have seen, when 'solve' is faced with a situation where the number of valid solutions may depend on the particular values of these parameters in a complicated way, it can produce very awkward solutions which may involve values that must be discarded such as complex or negative values. The chances of finding an efficient formula then become rather small.
In your particular problem I would forget about 'solve' altogether and solve the problem using other techniques. One approach would be to first use a coordinate system (u,v) that is rotated about the origin so that the point (s,t) lies on the positive uaxis. The rotation angle would be
theta = atan2(t,s);
Relative to the u,v coordinates we have a triangle with vertices A = (u,v), B = (a,0), and C = (0,0), where a = sqrt(s^2+t^2) and where B is the (s,t) point lying on the uaxis. Call the corresponding adjacent angles alpha, beta, and gamma, and call the opposite sides a, b, and c. Thus we are given sides a, and b and angle alpha, and we must find u and v. Using the cosine law we can solve for c as:
c = b*cos(alpha) + sqrt(a^2b^2*sin(alpha)^2);
(The other quadratic solution would be negative for a > b, so it is discarded.)
We can then obtain u = b*cos(gamma) which, again using the cosine law, becomes:
u = b/a*(b*sin(alpha)^2cos(alpha)*sqrt(a^2b^2*sin(alpha)^2));
Next v = b*sin(gamma) and using the sine law this gives:
v = b*c/a*sin(alpha);
A second symmetrically opposite pair (u,v) must also be a solution.
The two corresponding (x,y) solutions would then be:
x1 = u*cos(theta)v*sin(theta);
y1 = u*sin(theta)+v*cos(theta);
x2 = u*cos(theta)+v*sin(theta);
y2 = u*sin(theta)v*cos(theta);
Obviously the sequence of matlab steps can be made more efficient by evaluating sine and cosine of alpha and theta only once and storing the results. The same is true of such expressions as the above square root: "sqrt(a^2b^2*sin(alpha)^2)"
Roger Stafford
