def _get_weights(self, X, Y):
"""
This private method, given the original control points and the deformed
ones, returns the matrix with the weights and the polynomial terms, that
is :math:`W`, :math:`c^T` and :math:`Q^T`. The shape is
(n_control_points+1+3)-by-3.
:param numpy.ndarray X: it is an n_control_points-by-3 array with the
coordinates of the original interpolation control points before the
deformation.
:param numpy.ndarray Y: it is an n_control_points-by-3 array with the
coordinates of the interpolation control points after the
deformation.
:return: weights: the matrix with the weights and the polynomial terms.
:rtype: numpy.matrix
"""
n_points = X.shape[0]
dim = X.shape[1]
identity = np.ones((n_points, 1))
dist = self._distance_matrix(X, X)
H = np.bmat([
[dist, identity, X],
[identity.T, np.zeros((1, 1)), np.zeros((1, dim))],
[X.T, np.zeros((dim, 1)), np.zeros((dim, dim))]
])
rhs = np.bmat([[Y], [np.zeros((1, dim))], [np.zeros((dim, dim))]])
weights = np.linalg.solve(H, rhs)
return weights
评论列表
文章目录