# Creating Arc if you know center start and end point

**URL:** <https://discourse.processing.org/t/creating-arc-if-you-know-center-start-and-end-point/2338>\
**Category:** Coding Questions\
**Created:** [August 3, 2018, 6:11pm UTC](https://discourse.processing.org/t/creating-arc-if-you-know-center-start-and-end-point/2338 "2018-08-03T18:11:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rebin/32/994_2.png) [@rebin](https://discourse.processing.org/u/rebin)\
**Post date:** [August 3, 2018, 6:11pm UTC](https://discourse.processing.org/t/creating-arc-if-you-know-center-start-and-end-point/2338/1 "2018-08-03T18:11:16Z")

</div>

Hi all;  
This is my first question so apologize if I do not follow the rule properly.

I need to create an arc in processing. but I believe ( maybe I am wrong) the way I wanted the arc function arc( _x_ , _y_ , _width_ , _height_ , _start_ , _stop_ ) does not help me…  
here is what I want:

I need to create arc that I know the following information about the arc:  
center, radius, start point ( x,y) and (x\_end,y\_end). and let say we go counterclockwise so the arc to be unique.

is there is anyway to do this efficiently ?  
thanks

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [August 3, 2018, 6:31pm UTC](https://discourse.processing.org/t/creating-arc-if-you-know-center-start-and-end-point/2338/2 "2018-08-03T18:31:31Z")

</div>

Can you use trigonometry to convert the start and end points into angles?

---

<div class="post-metadata">

**Author:** ![behreajj](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@behreajj](https://discourse.processing.org/u/behreajj)\
**Post date:** [August 3, 2018, 6:54pm UTC](https://discourse.processing.org/t/creating-arc-if-you-know-center-start-and-end-point/2338/3 "2018-08-03T18:54:59Z")

</div>

Hi rebin,

If you want the arc to be circular, you could think of the three points that you know as a triangle. You could then find the circumcircle of the triangle. There is an example of such code at OpenProcessing [here](https://www.openprocessing.org/sketch/187085).

The center of the circumcircle would not necessarily be the point you label as ‘center’, or even be within the triangle formed by your three points. Nor would the radius of the arc be what you had planned it to be.

Consider the following code, where the distance between the start and center points may not equal the distance between the end and center points.

```auto
float startx, starty, endx, endy, centerx, centery, 
  diststart, distend;

void setup() {
  size(200, 200);
  ellipseMode(RADIUS);
  startx = random(0, width);
  starty = random(0, height);
  endx = random(0, width);
  endy = random(0, height);
  centerx = random(width * 0.25, width * 0.75);
  centery = random(height * 0.25, height * 0.75);
  diststart = dist(startx, starty, centerx, centery);
  distend = dist(endx, endy, centerx, centery);
}

void draw() {
  background(255.0);
  stroke(0.0);
  strokeWeight(1.0);
  line(centerx, centery, startx, starty);
  line(centerx, centery, endx, endy);
  noFill();
  ellipse(centerx, centery, diststart, diststart);
  ellipse(centerx, centery, distend, distend);
}

```

Instead of drawing the full circumcircle, you could then use `arc` after you’ve calculated the shortest angular distance. I usually do this when smoothing travel across a circumference over a step in time, so maybe [that logic](https://gist.github.com/behreajj/1674e49ecea484340905483da73163ea) would be helpful.

Best,
