6
\$\begingroup\$

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?

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Ani Aug 12 '13 at 9:14
  • \$\begingroup\$ @Ani The formulae for circumcircle involve only x and y, but a 3D triangle, in 3-space plane, uses x, y and z variables. \$\endgroup\$ – bobobobo Aug 12 '13 at 15:14
  • \$\begingroup\$ 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 \$\endgroup\$ – Ani Aug 13 '13 at 9:56
  • \$\begingroup\$ 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 \$\endgroup\$ – bobobobo Aug 13 '13 at 14:36
14
\$\begingroup\$

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()) ;
float circumsphereRadius = toCircumsphereCenter.len() ;

// 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

enter image description here

\$\endgroup\$
-1
\$\begingroup\$

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);
    return divv(addallv(x,y,z),a+b+c);
}

function centroid(A,B,C) {
    return divv(addallv(A,B,C),3);
}

function midpoint(A,B) {
    return divv(addv(A,B),2);
}

function orthocenter(A,B,C) {
    var c = circumcenter(A,B,C);
    return addallv(subv(A,c),subv(B,c),subv(C,c),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);
    return addv(midpoint(A,B),multv(normaliz(crossprod(subv(A,B),z)),r));
}

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.

Screenshot of pool example linked above after clicking Pyramid button

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Bálint Jul 11 at 10:04
  • \$\begingroup\$ @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. \$\endgroup\$ – DMGregory Jul 11 at 10:15
  • \$\begingroup\$ thanks for the help but its find not fint. and its more than "twice." (more models) \$\endgroup\$ – greenthings Jul 11 at 11:11
  • \$\begingroup\$ 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. \$\endgroup\$ – greenthings Jul 11 at 12:21
  • \$\begingroup\$ "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 \$\endgroup\$ – greenthings Jul 13 at 11:10

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.