Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

See attached image. The point P1 is at the end of a line, the line has the angle At1. The point P2 is at the beginning of a line with the angle At2. I know the coordinates for P1 and P2. I also know the angles At1 and At2. A radius is formed between P1 and P2 and I need to know the center point Pc for the (invisible) circle the which is formed with P1, P2, At1 and At2. The points P1 and P2 can be anywhere in the coordiante system.

I'm developing a c# application and I need some code for theese calculations.

//Thomas

centerpoint.png

I'm developing a c# application and I need some code for theese calculations.

//Thomas

centerpoint.png

Do more with

EXPERT OFFICE^{®} is a registered trademark of EXPERTS EXCHANGE^{®}

Since a tangent on the circumference of a circle is perpendicular to the radius, if you draw perpendicular lines to the 2 straight lines at points P1 and P2, the intersection of these two perpendicular lines will at the center of the circle of which the arc P1-P2 is a part of the circumference.

I am assuming that the two lines are parallel to each other and to the X-axis.

Point P2 is drawn slightly above the second line, so I assume P2 in NOT on the line.

Are these assumptions correct?

2. Draw a straight line that passes through the points P1 and P2, calling it Line AB.

Next, draw a line midway between these two points perpendicular to it, calling it Line CD

3. For Pc to be the centre of a circle whose points P1 and P2 form an arc, then Pc can ONLY be on the line CD.

4. The slope of the line AB is given by:

SlopeAB =((y2-y1) / (x2-x1 ))

where P1 (x1,y1) and P2 (x2,y2).

5, Since the line CD is perpendicular to AB, its slope will be the inverse reciprocal of AB, that is

SlopeCD=-1/SlopeAB

6.From the standard equation of a straight line:

y=mx+c

We get the equation of the line CD:

y=(1/SlopeCD) x + b

where b = the coordinates of the line where it crosses the Y-Axis.

In conclusion,

In your graph, the point Pc is a point floating in space between the two parallel lines, with no obvious link to any other feature on the map except the assertion that P1 and P2 form an arc from a circle for which Pc is the centre.

This means that, from your supplied information, the only thing you can say is that the point Pc must line on the line CD. Thus, all you can do is test the X and Y coordinates of a proposed point PC and see if they lay on that line.

Problem is I don't know C#, I don't know how you manipulate 2D vectors, and I haven't had enough coffee, but lets have a go:

N1 is a unit vector of At1 + 90 degrees

N2 is unit vector along At2 + 90 degrees

D is a unit vector along At1

offset = dotproduct (P2, D) - dotproduct (P1, D)

slope = dotproduct (N2, D)

Pc = P1 - N1 * (offset / slope)

It produces divide by zero if the lines are parallel, slope will be zero. Thats the basic principle. I'm pretty sure the math here is correct, you might have to negate or point a vector in the opposite direction.

This could be mathematically equivalent to the answer Orcbighter gave, but using vector math. I'm not sure, but if it is give the points to him.

In Figure1 these conditions are shown:

1) The solution is an arc of circle (as stated in the question)

2) Line_5 must be perpendicular to given Line_1 at point P1

3) Line_6 must be perpendicular to given Line_2 at point P2

4) Line_3 pass through points P1 and P2

5) Line_4 must be perpendicular to Line_3

6) Line_4 pass ny the middle point between P1 and P2

7) Distance P1 to Pc must be equal to rhe distance P2 to Pc

If any of the above conditions is not present, the problem hasn't a solution.

To solve the problem with a general solution, that is, to construct an arc tangent to any two lines at any two points, the arc must be an eliptical arc, not a circle arc. The solution would be a circle arc in the specific case as the above conditions.

Another approach is to construct two circle arcs, such that they have concordance (tangency continuity).

In figure 2 we see, in 2a, the lines and points as stated by the problem.

In 2b, rhe auxiliary lines (Line_3 and Line_4, in blue, perpendicular to the given lines at the points P1 and P2.

In 2c, in red, the Lines 7 and 8, extension lines of Lines 1 and 2 respectively; in green, Lines 5 and 6, parallel to Lines 4 and 6 respectively. The green lines define point P4; the red lines define point P3. These points, P3 and P4 define Line_9. Pc1 is the point where Line_9 crosses Line_3; Pc2 is where Line_9 crosses Line_4. Pc1 and Pc2 are the centers of the arcs which solve the problem.

In Figure 3, the arc P1-P6 has center in Pc1 and radius Pc1-P1; the arc P2-P6 has center in Pc2 and radius Pc2-P2.

In my oppinion, it is simpler than the eliptical approach, although this second one is feasible as well.

Jose

Concordance-1.jpg

Concordance-2.jpg

Concordance-3.jpg

## Premium Content

You need an Expert Office subscription to comment.Start Free Trial