__author__ = 'thoth'
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]) )
|
Blender python API quick-start
Syntax highlighting by Pygments.