@classmethod
    def vertex_aligned_locator(cls):
        selection = pm.ls(os=1, fl=1)

        # get the axises
        p0 = selection[0].getPosition(space='world')
        p1 = selection[1].getPosition(space='world')
        p2 = selection[2].getPosition(space='world')

        v1 = p0 - p1
        v2 = p2 - p1
        #v3 = p0 - p2

        v1.normalize()
        v2.normalize()

        dcm = pm.createNode('decomposeMatrix')

        x = v1
        z = v2
        y = z ^ x
        y.normalize()

        dcm.inputMatrix.set(
            [x[0], x[1], x[2], 0,
             y[0], y[1], y[2], 0,
             z[0], z[1], z[2], 0,
                0,    0,    0, 1], type='matrix')

        loc = pm.spaceLocator()

        loc.t.set(p1)
        loc.r.set(dcm.outputRotate.get())

        pm.delete(dcm)
creates vertex aligned locator, select 3 vertices
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/toolbox.py/Modeling.vertex_aligned_locator