# How do I find the circumcenter of a triangle in 3D?

I want to find the circumcenter of a triangle. Wolfram only shows how to find the circumcircle of a triangle in R2. How can I find the circumcenter of a triangle in R3?

• You can define a plane using the 3 points of a triangle and then the problem is back into R^2 for which you already know the method.
– Ani
Aug 12, 2013 at 9:14
• @Ani The formulae for circumcircle involve only x and y, but a 3D triangle, in 3-space plane, uses x, y and z variables. Aug 12, 2013 at 15:14
• what I meant was a unique plane can be defined using the 3 vertex of the triangle and in that reference plane, the triangle is 2D. This will however require appropriate transforms (which I did not elaborate) and hence just put this as a guiding comment rather than answer
– Ani
Aug 13, 2013 at 9:56
• Yes, in fact I thought I was going to have to rotate the triangle to the xy/xz/yz plane, then apply the 2d formula. Hence why I shared the Triangle in R^3 formula I found at Geometry Junkyard below Aug 13, 2013 at 14:36

The circumcenter of a triangle can be found by the following formula, which I mined from an old posting by Jonathan Shewchuk from the Geometry Junkyard

\begin{align} &\text{Triangle in } \Bbb R^3\text{:}\\ &m = a + \frac {\lVert c-a\rVert^2 \left[(b-a) \times (c - a) \right] \times (b-a) + \lVert b-a\rVert^2 \left[(c-a) \times (b - a) \right] \times (c-a)} {2 \lVert (b - a) \times (c - a) \rVert^2} \end{align}

Where $$\m\$$ is the circumcenter of the triangle.

Some C++ code, given Vector3f's with overloaded +, -,

Vector3f a,b,c // are the 3 pts of the tri

Vector3f ac = c - a ;
Vector3f ab = b - a ;
Vector3f abXac = ab.cross( ac ) ;

// this is the vector from a TO the circumsphere center
Vector3f toCircumsphereCenter = (abXac.cross( ab )*ac.len2() + ac.cross( abXac )*ab.len2()) / (2.f*abXac.len2()) ;

// The 3 space coords of the circumsphere center then:
Vector3f ccs = a  +  toCircumsphereCenter ; // now this is the actual 3space location


Here is a picture of a triangle and its circumsphere

• len2() is squared length ? Sep 11, 2023 at 9:17

JavaScript - MY WORK - 5 TRIANGLE CENTERS IN 3D

function incenter(A,B,C) {
var a=vlen(subv(A,B)),b=vlen(subv(B,C)),c=vlen(subv(C,A));
var x = multv(C,a), y = multv(A,b), z = multv(B,c);
}

function centroid(A,B,C) {
}

function midpoint(A,B) {
}

function orthocenter(A,B,C) {
var c = circumcenter(A,B,C);
}

function circumcenter(A,B,C) {
var z = crossprod(subv(C,B),subv(A,B));
var a=vlen(subv(A,B)),b=vlen(subv(B,C)),c=vlen(subv(C,A));
var r = ((b*b + c*c - a*a)/(2*b*c)) * outeradius(a,b,c);
}

function nine_point(A,B,C) {
return midpoint(orthocenter(A,B,C),circumcenter(A,B,C));
}

function outeradius(a,b,c) { /// 3 lens
return (a*b*c) / (4*sss_area(a,b,c));
}

function sss_area(a,b,c) {
var sp = (a+b+c)*0.5;
return Math.sqrt(sp*(sp-a)*(sp-b)*(sp-c));
//semi perimeter
}


If you need the remaining functions, you can fint them in this working code example - hit the pyramid button twice.

• This isn't a good answer. You use a lot of functions, that aren't self explanatory and aren't included in vanilla JS. divv, addallv, etc. Jul 11, 2019 at 10:04
• @Bálint since the question asks for an algorithm, not tagged with a specific language, I think this is no worse than the accepted answer that assumes a suitable definition of Vector3f in a C++ program. That answer doesn't define the cross or len2 methods, but we can infer they're the cross product and squared length reasonably easily, just the way in this answer we can infer that addallv sums the provided vector arguments, and divv does scalar multiplication between a vector and the reciprocal of a scalar. I certainly wouldn't complain about more explanation, but it's legible as-is. Jul 11, 2019 at 10:15
• thanks for the help but its find not fint. and its more than "twice." (more models) Jul 11, 2019 at 11:11
• hmf, looks like gravity was busted, found the error. Sorry, get the new file. and ctrl-f5 is supposed to reload but ... oh well. and given the response well ... I know better. no good deed goes ... outta here. make something cool and quit asking questions. all u need is one good program and your done asking questions. Jul 11, 2019 at 12:21
• "I think this is no worse than the accepted answer that assumes" uhm, you wont ever see a better more complete example for triangles centers, and if you ever do, call me lol Jul 13, 2019 at 11:10
//Unity/C#
Vector3 ac = c - a;
Vector3 ab = b - a;
Vector3 abXac = Vector3.Cross(ab, ac);

// this is the vector from a TO the circumsphere center
Vector3 toCircumsphereCenter = (Vector3.Cross(abXac,ab) * ac.sqrMagnitude + Vector3.Cross(ac,abXac) * ab.sqrMagnitude) / (2f * abXac.sqrMagnitude);