I know I am not the first one to solve this problem. I am hoping
there is a simpler solution to the one I have.
BTW, my two points and a radius Scilab routine is
// Given r, x0, y0, x1, y1
x0=-1.0;
y0=0.0;
x1=0.0;
y1=1.5;
r=1; // radius of circle/turn
U=(x1-x0)^2+(y1-y0)^2; // Think of U as R^2
Q=sqrt((4*r^2-U)/U);
Center1=0.5* [ 1 -Q 1 Q ; Q 1 -Q 1 ]*[ x0 ; y0 ; x1 ; y1 ];
Center2=0.5* [ 1 Q 1 -Q ; -Q 1 Q 1 ]*[ x0 ; y0 ; x1 ; y1 ];
disp(Center1,Center2);
I am looking for a similar efficient method for finding the center of
the circle for two lines and a radius. I am sure it will be more
complicated but my current method uses the cosine law to find the
angle between the two vectors. The sine law to find the distance from
the intersection of the two vectors to the center of the circle, an
atan2 to compute the direction of motion and finally a sin and cos
function to calculate the center point relative to the intersection of
the two points. There must be a simpler way.
Peter Nachtwey
Peter Nachtwey
Slide point 2 along the line connecting it to point 1 until
it's just as far from point 1 as point 0 is. Call that point 3.
Let point 4 be the average of points 0 and 3.
Slide point 4 along the line connecting it to point 1 until
its distance from the line conecting point 0 to point 1 is r.
Peter Nachtwey
Peter Nachtwey
As far as I can see the problem boils down to solving the linear system
det(v, v1-v0) / ||v1-v0|| = +/-r
det(v, v2-v1) / ||v2-v1|| = +/-r
If you can define whether v should be "to the left" or "to the right" of
v1-v0 and v2-v1 respectively then you know which of +/- to choose and
you're done. If you don't know that, what do you know?
--
Niels Diepeveen