# Drawing half a circle betweeen two arbitrary 2D points

So, I have two arbitrary points in a vector space and I'm trying to draw 180 degrees of a circle between them. The radius of the circle would be half of the distance between the two points and the first points in the circle should solidly be the original two 2D points.

How should I go about creating this? Thank you.

• Create in what sense? Using a ruler and compass on paper? – Paul Feb 10 '16 at 9:28
• I'm trying to create it by code, sorry for being unclear. Though being able to create it on paper point by point would be sufficient enough. Basically some sort of function or ruleset to follow along to create at least 20 points of a 180 degree slice of a circle from two points, could be me following the function to draw the points on paper one by one, or a bit of code following a similar idea. – Bun Feb 10 '16 at 9:32

If you want to code a function which gives you $n$ points of that half circle you could proceed as follow:

Let $\vec a=(a_1,a_2)$ and $\vec b=(b_1,b_2)$ your two points defining the "ends" of the half circle.

Then the center is clearly $\vec c = (\vec a + \vec b)/2$ and the radius $r=|\vec a-\vec b|/2$ The angle where $\vec a$ is corresponding to the Center repectivly by the top.

$$\theta_a=\text{atan2}(a_1-c_1,a_2-c_2)$$ And for $\vec b$: $$\theta_b=\text{atan2}(b_1-c_1,b_2-c_2)$$

You know atan2? A great function in many coding languages.

For a check $|\theta_a - \theta_b| = 180°$ should be.

Then the angle between your plotting points is $\Delta \theta=180°/(n+1)$

Now you can write the for loop (using C syntax)

flaot[] x = new float[n];
flaot[] y = new float[n];
float theta = min(theta_a, \theta_b); // Here you can decide on which side the half circle should be.
for(int i=0; i < n;i++){
theta += delteTheata;
x[i] = r*sin(theta);
y[i] = r*cos(theta);
}

• I hope I did not make any bad mistake. Write a comment if I did. – Matthias Feb 10 '16 at 9:49