Exemplo n.º 1
0
def mag_superimpose(a1, a2):

    sup = SVDSuperimposer()

    a1 = np.asarray(a1)
    a2 = np.asarray(a2)
    mags = [norm(v) for v in a2]

    if len(a1) <= 7:

        min_dist = (1.0E6, 'foo', 'bar')

        for l in itertools.permutations(a1):

            p = np.array([m * v / norm(v) for m, v in zip(mags, l)])
            sup.set(a2, p)
            sup.run()
            rot, tran = sup.get_rotran()
            rms = sup.get_rms()

            if rms < min_dist[0]:
                min_dist = (rms, rot, tran)

    else:

        a1, a2 = match_vectors(a1, a2, 6)
        mags = [norm(v) for v in a2]

        min_dist = (1.0E6, 'foo', 'bar')

        for l in itertools.permutations(a1):

            p = np.array([m * v / norm(v) for m, v in zip(mags, l)])
            sup.set(a2, p)
            sup.run()
            rot, tran = sup.get_rotran()
            rms = sup.get_rms()

            if rms < min_dist[0]:
                min_dist = (rms, rot, tran)

    return min_dist
Exemplo n.º 2
0
def superimpose(a1,a2):
	
	sup = SVDSuperimposer()

	a1 = np.asarray(a1)
	a2 = np.asarray(a2)

	if len(a1) <= 7:

		min_dist = (1.0E6, 'foo', 'bar')
		
		for l in itertools.permutations(a1):
			p = np.asarray(l)
			sup.set(a2,p)
			sup.run()
			rot,tran = sup.get_rotran()
			aff_a1 = np.dot(l,rot) + tran
			rms = sup.get_rms()

			if rms < min_dist[0]:
				min_dist = (rms,rot,tran)
	
	else:

		a1,a2 = match_vectors(a1,a2,6)
		
		min_dist = (1.0E6, 'foo', 'bar')
		
		for l in itertools.permutations(a1):
			p = np.asarray(l)
			sup.set(a2,p)
			sup.run()
			rot,tran = sup.get_rotran()
			aff_a1 = np.dot(l,rot) + tran
			rms = sup.get_rms()
		
			if rms < min_dist[0]:
				min_dist = (rms,rot,tran)

	return min_dist
Exemplo n.º 3
0
# start with two coordinate sets (Nx3 arrays - Float0)

x = array([[51.65, -1.90, 50.07], [50.40, -1.23, 50.65], [50.68, -0.04, 51.54],
           [50.22, -0.02, 52.85]], 'f')

y = array([[51.30, -2.99, 46.54], [51.09, -1.88, 47.58], [52.36, -1.20, 48.03],
           [52.71, -1.18, 49.38]], 'f')

sup = SVDSuperimposer()

# set the coords
# y will be rotated and translated on x
sup.set(x, y)

# do the lsq fit
sup.run()

# get the rmsd
rms = sup.get_rms()

# get rotation (right multiplying!) and the translation
rot, tran = sup.get_rotran()

# rotate y on x manually
y_on_x1 = dot(y, rot) + tran

# same thing
y_on_x2 = sup.get_transformed()


def simple_matrix_print(matrix):
Exemplo n.º 4
0
         [50.68, -0.04, 51.54],
         [50.22, -0.02, 52.85]], 'f')

y=array([[51.30, -2.99, 46.54],
         [51.09, -1.88, 47.58],
         [52.36, -1.20, 48.03],
         [52.71, -1.18, 49.38]], 'f')

sup=SVDSuperimposer()

# set the coords
# y will be rotated and translated on x
sup.set(x, y)

# do the lsq fit
sup.run()

# get the rmsd
rms=sup.get_rms()

# get rotation (right multiplying!) and the translation
rot, tran=sup.get_rotran()

# rotate y on x manually
y_on_x1=dot(y, rot)+tran

# same thing
y_on_x2=sup.get_transformed()

def simple_matrix_print(matrix):
    """Simple string to display a floating point matrix