How to create a Rotation Matrix in Tensorflow
with two operations:
def rotate(tf, points, theta):
rotation_matrix = tf.pack([tf.cos(theta),
-tf.sin(theta),
tf.sin(theta),
tf.cos(theta)])
rotation_matrix = tf.reshape(rotation_matrix, (2,2))
return tf.matmul(points, rotation_matrix)
To answer the question of 'How to build a Rotation Matrix', the following is cleaner than requiring a multiple pack
(stack
) calls:
tf.stack([(tf.cos(angle), -tf.sin(angle)), (tf.sin(angle), tf.cos(angle))], axis=0)