Skip to content

How to reproduce transformation on other data? #200

Answered by studywolf
studywolf asked this question in Q&A
Discussion options

You must be logged in to vote

Nevermind, resolved!

import matplotlib.pyplot as plt
import numpy as np
import procrustes


A = np.random.random((3, 3))
B = np.dot(A, np.array([[np.cos(2), -np.sin(2), 0], [np.sin(2), np.cos(2), 0], [0, 0, 1]])) * 10 + 4

r = procrustes.orthogonal(A, B, scale=True, translate=True)

_, a_c = procrustes.utils._translate_array(A, None)
_, a_s = procrustes.utils._scale_array(A + a_c, None)

_, b_c = procrustes.utils._translate_array(B, None)
_, b_s = procrustes.utils._scale_array(B + b_c, None)

transformation_matrix = r.t

AT = np.dot((A + a_c) * a_s, r.t)
nb = (B + b_c) * b_s
ATB = AT / b_s - b_c
print(f"{AT=}")
print(f"{r.new_b=}")
print(f"{AT / b_s - b_c=}")
print(f"{B=}")

fig = plt.fig…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FanwangM
Comment options

Answer selected by FanwangM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants