Skip to content

Instantly share code, notes, and snippets.

@eborghi10
Created April 12, 2020 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eborghi10/da82c476c155660815461fc491759379 to your computer and use it in GitHub Desktop.
Save eborghi10/da82c476c155660815461fc491759379 to your computer and use it in GitHub Desktop.
Tf example with numpy
#!/usr/bin/env python
import numpy as np
# Define the position of the frame B w.r.t. A
a_T_b = np.array([[2, -1, 1]]).transpose()
# Define the orientation of the frame B w.r.t. A
theta = np.radians(-90)
c, s = np.cos(theta), np.sin(theta)
a_R_b = np.array(((c, -s), (s, c), (0, 0)))
# Homogeneous matrix between A and B
a_H_b = np.concatenate((a_R_b, a_T_b), axis=1)
# The point 'p' in the frame B
b_p = np.array([[1, 1, 1]]).transpose()
# Get the resulting point w.r.t the frame A
a_p = a_H_b.dot(b_p)[0:2]
print(a_p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment