# How can I determine/calculate a circumcenter with 3 points

I wanted to calculate the circumcenter of an object (for example of an cylinder).

For this purpose I use Z-mode to see the grid of an object and mark three points that are on the same circle. After this I calculate the circumcenter on paper and set my 3D cursor to those values.

Is there an addon/widget/plugin/script that I can add to Blender to archive the same without the hassle of manually calculating or can Blender do that by itself?

The main goal I have is to get the midpoint of a circle object in Blender. If the calculation with 3 points is unneeded and over complicating things tell me so please.

Furthermore sadly I do not find calculators online who support 3D vectors for this calculation. So If you can link me a calculator for tempory usage would be great too.

• If you only want the midpoint, you could also calculate the center by the object's bounding box (the dimensions of an object) or is this not accurate enough in your case? – p2or Apr 8 '15 at 13:01
• No absolutely not. The circle is not even near the center of the entire object. But I will keep it in my mind if I cross an circle only/center object, thanks! – Wandang Apr 8 '15 at 13:06

I have written such a tool, it creates a grease-pencil representation of the reconstructed circle if you can select 3 vertices of an incomplete circle. It also allows you to change the number of vertices of the new representation.

You can easily convert from grease pencil to mesh

6 mb example image

• Tremendous work you did there! Could you tell me how to select multiple vertices too? Thanks in advance, you saved my week! – Wandang Apr 8 '15 at 13:34
• I do not have those points/vertices. My circle is one continuous orange line. Maybe because my object was an import from an stl file. – Wandang Apr 8 '15 at 13:40
• well, if you imported it it's probably a mesh, maybe a very finely divided mesh, or is it a Curve Object? I thought STL was only triangles. – zeffii Apr 8 '15 at 13:42
• place your imported object in Edit Mode then you can select vertices – zeffii Apr 8 '15 at 13:43
• any feedback issues about the addon / operator should happen on github, while it works for my needs I am open to ideas. Remember the code is Free and Open source you can modify it to your own specifications if I don't want to implement ideas :) – zeffii Apr 8 '15 at 13:58

I cobbled together some python which computes the center of the circle through the 3 selected vertices of a mesh and assigns the 3D cursor to that location.

http://web.purplefrog.com/~thoth/blender/python-cookbook/compute-circle-center.html

You can paste that code into a blender Text Editor window and Run Script. Here is a copy of the code in-line:

import bpy
import bmesh
from mathutils import *

def replace_col(M, i, C):
for r in range(len(M)):
M[r][i] = C[r]

def compute_circle_center_(B, C, N):

m_d = Matrix( [
B,C,N
])

col = [B.dot(B)*0.5,
C.dot(C)*0.5,
0]

m_x = m_d.copy()
replace_col(m_x, 0, col)

m_y = m_d.copy()
replace_col(m_y, 1, col)

m_z = m_d.copy()
replace_col(m_z, 2, col)

m_d_d = m_d.determinant()

x = m_x.determinant() / m_d_d
y = m_y.determinant() / m_d_d
z = m_z.determinant() / m_d_d

#print(m_d)
#print(m_x)
#print(m_y)
#print(m_z)

return Vector([x,y,z])

def compute_circle_center(A,B,C):
#print ("%r\t %r\t %r"%(A,B,C))
B_ = B-A
C_ = C-A
N = B_.cross(C_)
#print ("%r\t %r\t %r"%(B_,C_, N))

return A+compute_circle_center_(B_, C_, N)

def space_3d():
for area in bpy.context.screen.areas:
for space in area.spaces:
if space.type=='VIEW_3D':
return space
raise AssertionError("could not find any editor space of type VIEW_3D")

def mission():
obj = bpy.context.active_object
verts=[]
if bpy.context.mode == 'EDIT_MESH':
bm = bmesh.from_edit_mesh(obj.data)
for v in bm.verts:
if v.select:
verts.append(obj.matrix_world * v.co)
else:
for v in obj.data.vertices:
if v.select:
verts.append(obj.matrix_world * v.co)
if len(verts) != 3:
raise AssertionError("You must select exactly 3 vertices from the mesh, not %d"%len(verts))

space_3d().cursor_location = compute_circle_center(verts[0], verts[1], verts[2])

#
#
#

mission()