cloning
link-mesh-array.py
link-mesh.py

mesh fabrication
staircase.py
triangle-donut.py
vertexAccumulator.py
randomSquareArray.py
meshFromBathymetry.py
cylinders-from-list-of-radii.py
binary-image-to-mesh.py
sphere-minecraft-schematic.py
spikify.py
add-to-mesh.py
mobius-strip.py
split-copy-mesh.py

fabricating other objects
create-text.py
text-from-file.py
create-camera.py
create-bezier.py
helix-bezier.py

material slots
cube-copy-blue.py
cube-turns-red.py
red-blue-per-object.py

animation and fcurves
csv-to-fcurve-loc-rot.py
csv-to-fcurve.py
pop-in-material.py
spike-wiggle-2.py
spike-wiggle.py
sweep-animate-size.py
animate-cycles-lamp-strength.py

incorporating python libraries
exec-text-library.py
exec-external-python.py
import-python.py

constraints
camera-track-object.py
text-track-camera.py

shape keys
explore-shape-keys.py
shape-key-fin.py
docking-tube.py

animating curve bevel
data-graph.py

drivers
scan-drivers.py
copy-drivers.py
driver-fin.py
driver-multi-chain.py

UV layers
barber-pole.py
expand-uv-to-fit.py
uv-from-geometry-cubic.py
flip-texture-v-coordinate.py

modifiers
hook-modifier-curve.py
rounded-prisms.py
make-tile.py
remove-action-modifiers.py

NLAs
explore-NLAs.py
spinning-frogs.py

video sequence editor (VSE)
create-vse-image-strips.py
slide-show.py
vse-strip-gap.py

images and textures
image-on-mesh.py
image-to-material-node.py
load-image-texture.py
texture-one-cube-face.py
condense-duplicate-images.py

analytic geometry
animate-random-spin.py
camera-cone-exp-2.py
camera-cone-exp.py
compute-circle-center.py
dihedral-angle-from-xy.py
extrude-edge-along-custom-axis.py
orientation-matrix.py
two-spheres.py
bezier-interpolate.py
rotate-to-match.py

node trees
change-diffuse-to-emission-node.py

etc
add-plane-from-selected-vertices.py
adjust-all-materials.py
all-nodes-cycles-materials.py
bit_shift.py
bone-orientation-demo.py
cannonball-packing.py
comb.py
convert-quaternion-keyframes-to-euler.py
copy-location-from-vertex-group.py
create-cycles-material.py
demonstrate-decomposition-instability.py
dump-point-cache.py
dump-screen-layout-info.py
expand-nla-strips.py
explore-edge-bevel-weight.py
find-action-users.py
find-green-rectangle.py
find-new-objects.py
fix-scene-layers.py
generate-makefile.py
link-external-data-blocks.py
list-referenced-files.py
material-readout.py
movie-card-stack.py
movies-on-faces.py
next-file-name.py
object-font-from-regular-font.py
operator-mesh-gridify.py
particle-animator.py
particle_loop.py
pose-match.py
pose-sequence-to-fbx.py
prepare-texture-bake.py
raining-physics.py
random-pebble-material.py
reverse-keyframes.py
scale-parallelogram.py
screenshot-sequence.py
select-objects-in-modifiers.py
select-vertices.py
shift-layers.py
snapshot-keyframes-as-mesh.py
sphere-project-texture.py
squish-mesh-axis.py
subdivide-fcurve.py
thicken-texture.py
transform-selected.py
voronoi-madness.py

__author__ = 'thoth'

#
# for
# http://blender.stackexchange.com/questions/28239/how-can-i-determine-calculate-a-circumcenter-with-3-points/28260#28260
#

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):
    """
    Compute the center of a circle that includes points [0,0,0], B, and C
    """
    N = B.cross(C)

    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])

    latex = """\vec x \cdot \frac{\vec B}{\left | \vec B \right |} = \frac{1}{2}\left | \vec B \right |
\vec x \cdot \vec B = \frac{1}{2}\left | \vec B \right |^2
\vec x \cdot \vec C = \frac{1}{2}\left | \vec C \right |^2

\vec N = \vec B \times \vec C
\vec x \cdot \vec N = 0


x B_x + y B_y + z B_z = \frac{1}{2}(B_x^2+B_y^2+B_z^2) = b
x C_x + y C_y + z C_z = \frac{1}{2}(C_x^2+C_y^2+C_z^2) = c
x N_x + y N_y + z N_z = 0

x= \frac{\begin{vmatrix}
 b & B_y & B_z\\
 c & C_y & C_z\\
 0 & N_y & N_z
 \end{vmatrix}}{\begin{vmatrix}
 B_x & B_y & B_z\\
 C_x & C_y & C_z\\
 N_x & N_y & N_z
 \end{vmatrix}}

y= \frac{\begin{vmatrix}
 B_x & b & B_z\\
 C_x & c & C_z\\
 N_x & 0 & N_z
 \end{vmatrix}}{\begin{vmatrix}
 B_x & B_y & B_z\\
 C_x & C_y & C_z\\
 N_x & N_y & N_z
 \end{vmatrix}}

z= \frac{\begin{vmatrix}
 B_x & B_y & b\\
 C_x & C_y & c\\
 N_x & N_y & 0
 \end{vmatrix}}{\begin{vmatrix}
 B_x & B_y & B_z\\
 C_x & C_y & C_z\\
 N_x & N_y & N_z
 \end{vmatrix}}
"""

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

    return A+compute_circle_center_(B_, C_)

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()

Blender python API quick-start

Syntax highlighting by Pygments.