Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
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 '13 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. –  bobobobo Aug 12 '13 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 '13 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 –  bobobobo Aug 13 '13 at 14:36

1 Answer 1

up vote 3 down vote accepted

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

    Triangle in R^3:

        |c-a|^2 [(b-a)x(c-a)]x(b-a) + |b-a|^2 (c-a)x[(b-a)x(c-a)]
m = a + ---------------------------------------------------------.
                           2 | (b-a)x(c-a) |^2

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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