My attempt to construct transformation matrix using 3 vertices (didn't work, need help) Smart people in the past offered a solution to construct transformation matrix using 3 vertices:

How do I construct a transformation matrix from 3 vertices?

I tried to test it but I could not get it right. Please see attached code, screenshot, and blender file. 

I would like to align Suzanne origin to K and align Suzanne's y axis to the normal of the plane defined by (k, i, j). I don't need (i, j) beyond defining the plane. My problem is my code doesn't do it. And I couldn't figure out why.

Thanks!





# https://blender.stackexchange.com/questions/30808/how-do-i-construct-a-transformation-matrix-from-3-vertices

import bpy
from mathutils import *

# randomly selected 3 vertices
i = Vector((0.778421, 0.112746, 1.402834))
j = Vector((1.444566, 0.088229, 2.944015))
k = Vector((1.476759, 0.047526, 1.439882))

# to visualized the points
bpy.ops.mesh.primitive_uv_sphere_add(size=0.05, location=i)
bpy.ops.mesh.primitive_uv_sphere_add(size=0.05, location=j)
bpy.ops.mesh.primitive_uv_sphere_add(size=0.05, location=k)

a = i - k
b = j - k
c = a.cross(b).normalized() #y axis?
d = c.cross(a).normalized() #z axis?
e = c.cross(d).normalized() #x axis?

m = Matrix.Translation(k) * Matrix.Scale(1,4) * Matrix((e, c, d)).transposed().to_4x4()

obj = bpy.data.objects['Suzanne']
obj.matrix_world = m*obj.matrix_world
As answered by batfinger in the comment. Just change the last line to 

obj.matrix_wolrd = m


everything works well now. Thanks!