# Circumcircle of Triangle

**URL:** <https://discourse.processing.org/t/circumcircle-of-triangle/13030>\
**Category:** Coding Questions\
**Created:** [July 28, 2019, 10:55pm UTC](https://discourse.processing.org/t/circumcircle-of-triangle/13030 "2019-07-28T22:55:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![McTuble](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@McTuble](https://discourse.processing.org/u/McTuble)\
**Post date:** [July 28, 2019, 10:55pm UTC](https://discourse.processing.org/t/circumcircle-of-triangle/13030/1 "2019-07-28T22:55:45Z")

</div>

My ultimate goal in the use of this is to implement my own code to use for the Delaunay Triangulation algorithm. I hear all this talk about needing to find the circumcircle of a triangle and I am unsure about how to do this. I know I need to get the perpendicular bisector of each side and find where they intersect. I thought maybe I could get away with averaging each point but upon visual inspection it was not that easy. Any help in this regard would be greatly appreciated. I like math and am halfway decent at math but never could get the hang of understanding long math formulas. Thank you all.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 29, 2019, 12:29am UTC](https://discourse.processing.org/t/circumcircle-of-triangle/13030/2 "2019-07-29T00:29:01Z")

</div>

not sure some p5.js code helps, just take a look [circum\_circle](https://editor.p5js.org/kll/sketches/rJx_jpilD)

today ( and in processing JAVA ) i would try use PVector for the points.

---

<div class="post-metadata">

**Author:** ![McTuble](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@McTuble](https://discourse.processing.org/u/McTuble)\
**Post date:** [July 29, 2019, 1:38am UTC](https://discourse.processing.org/t/circumcircle-of-triangle/13030/3 "2019-07-29T01:38:50Z")

</div>

Thank you very much for your response. I will try to port it to processing JAVA tomorrow when I get a moment.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [July 30, 2019, 1:51pm UTC](https://discourse.processing.org/t/circumcircle-of-triangle/13030/4 "2019-07-30T13:51:41Z")

</div>

> [@McTuble](#):
>
> my own code to use for the Delaunay Triangulation algorithm

You might also be interested in looking at the implementation of Delaunay Triangulation in the Mesh library.

---

<div class="post-metadata">

**Author:** ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Post date:** [July 30, 2019, 10:21pm UTC](https://discourse.processing.org/t/circumcircle-of-triangle/13030/5 "2019-07-30T22:21:07Z")

</div>

this code worked for me:

```auto
    // * calculate circumcenter
    PVector a = points.get(vxs[0]).vx; //these are the three vertices of the triangle
    PVector b = points.get(vxs[1]).vx;
    PVector c = points.get(vxs[2]).vx;
    PVector ab = PVector.sub(b, a);
    PVector ac = PVector.sub(c, a);
    PVector c1 = ab.cross(ac);
    PVector c2 = ac.cross(ab);
    float d1 = PVector.dist(a, c1); // I don't actually remember why I needed to calculate both distances
    float d2 = PVector.dist(a, c2);
    if (d1<d2) {
      cc = c1; // cc is the circumcircle
    } else {
      cc = c2;
    }
    cc.normalize();

```

In my case all the vertices were normalized 3D vectors, so they all (including the calculated circumcircle were lying on a sphere of 1.0 radius with the center in the (0, 0, 0).
