The following python code from orientation-matrix.py illustrates how to convert 3 coordinates into a transformation matrix:
import bpy
from mathutils import *
def make_matrix(v1, v2, v3):
a = v2-v1
b = v3-v1
c = a.cross(b)
if c.magnitude>0:
c = c.normalized()
else:
raise BaseException("A B C are colinear")
b2 = c.cross(a).normalized()
a2 = a.normalized()
m = Matrix([a2, b2, c]).transposed()
s = a.magnitude
m = Matrix.Translation(v1) * Matrix.Scale(s,4) * m.to_4x4()
return m
#
obj = bpy.context.active_object
obj.matrix_world = make_matrix(Vector([1,1,1]), Vector([1,2.5,1]), Vector([0.5,1,1.5]) )
The Matrix.Scale is just thrown in for completeness and you can leave it out if you are content with scale=1. The order of the matrices in that multiplication is pretty important (I did not get it perfect on the first try).