Co-ordinate geometry.

I have a straight line with it’s start and end point coordinate. And I need to find center of arc with r radius and direction clockwise/ anti-clockwise according to requirement, making the line tangent to the arc(at end point of the line), such that only one center from possible should be picked.

Is it possible?

Program in java script or c# would be more fruitful to me.

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

  

 

Where are you having problems?
– Andrei
2 days ago

  

 

With given parameters I am not able to find the center of arc.(in coordinate)
– Ramesh
2 days ago

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

1 Answer
1

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

Here are the steps:

The initial coordinates of the line are (x1,y1)(x1,y1)(x_1,y_1), the end of the line is at (x2,y2)(x_2,y_2), where the arc is tangent to the line. The radius of curvature is RR. You need (x3,y3)(x_3,y_3), the center of the arc. You have two unknowns, so you need two equations.
Since (x2,y2)(x_2,y_2) is on the arc, it is at distance RR from the center. You can write this as (x2−x3)2+(y2−y3)2=R2(x_2-x_3)^2+(y_2-y_3)^2=R^2
The line from (x3,y3)(x_3,y_3) to (x2,y2)(x_2,y_2) is perpendicular to the line from (x2,y2)(x_2,y_2) to (x1,y1)(x_1,y_1), so the product of the slopes is −1-1. You can write this as
y2−y1x2−x1=−x3−x2y3−y2\frac{y_2-y_1}{x_2-x_1}=-\frac{x_3-x_2}{y_3-y_2}
You square the last equation, and you can put (y2−y3)2(y_2-y_3)^2 into the first equation. You are left with a simple equation for (x2−x3)2=f(x1,y1,x2,y2,R)(x_2-x_3)^2=f(x_1,y_1,x_2,y_2,R). This obviously has two solutions, one for clockwise arc, one for counterclockwise arc.
Look up vector product on wikipedia to find out about clockwise/counterclockwise rotations. It will involve choosing one of x3=x2±√f(x1,y1,x2,y2,R)x_3=x_2\pm\sqrt{f(x_1,y_1,x_2,y_2,R)}

  

 

Could you please explain how to choose the point according to given direction of arc (clockwise/ counterclockwise).
– Ramesh
2 days ago

  

 

In 3D space, you create vectors a=(x2−x1,y2−y1,0)a=(x_2-x_1,y_2-y_1,0), b=(x3−x2,y3−y2,0)b=(x_3-x_2,y_3-y_2,0). The cross product a×ba\times b will be a vector either along (0,0,1)(0,0,1) or (0,0,−1)(0,0,-1). When you write explicitly the formula for the cross product, all you need to do is to look at the last term (a function of x1,x2,x3,y1,y2,y3x_1,x_2,x_3,y_1,y_2,y_3). If it’s positive you have a counter clockwise arc. If it’s negative the arc is in the clockwise direction. Make sure that you multiply them in the correct order, otherwise cross product will change sign
– Andrei
2 days ago