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.

  • $\begingroup$ Create in what sense? Using a ruler and compass on paper? $\endgroup$ – Paul Feb 10 '16 at 9:28
  • $\begingroup$ 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. $\endgroup$ – 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);
  • $\begingroup$ I hope I did not make any bad mistake. Write a comment if I did. $\endgroup$ – Matthias Feb 10 '16 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.