def _setup_normalized_vectors(self, normal_vector, north_vector):
normal_vector, north_vector = _validate_unit_vectors(normal_vector,
north_vector)
mylog.debug('Setting normalized vectors' + str(normal_vector)
+ str(north_vector))
# Now we set up our various vectors
normal_vector /= np.sqrt(np.dot(normal_vector, normal_vector))
if north_vector is None:
vecs = np.identity(3)
t = np.cross(normal_vector, vecs).sum(axis=1)
ax = t.argmax()
east_vector = np.cross(vecs[ax, :], normal_vector).ravel()
# self.north_vector must remain None otherwise rotations about a fixed axis will break.
# The north_vector calculated here will still be included in self.unit_vectors.
north_vector = np.cross(normal_vector, east_vector).ravel()
else:
if self.steady_north or (np.dot(north_vector, normal_vector) != 0.0):
north_vector = north_vector - np.dot(north_vector,normal_vector)*normal_vector
east_vector = np.cross(north_vector, normal_vector).ravel()
north_vector /= np.sqrt(np.dot(north_vector, north_vector))
east_vector /= np.sqrt(np.dot(east_vector, east_vector))
self.normal_vector = normal_vector
self.north_vector = north_vector
self.unit_vectors = YTArray([east_vector, north_vector, normal_vector], "")
self.inv_mat = np.linalg.pinv(self.unit_vectors)
评论列表
文章目录