Skip to content

Commit

Permalink
Merge pull request #27 from tinkerfuroc/vision_doc
Browse files Browse the repository at this point in the history
fix bug in vec to quaternion code
  • Loading branch information
cdsfcesf authored Jul 10, 2024
2 parents 4945266 + 4e27b0c commit 56696d6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions docs/Documentation/Vision/cheat_sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,14 @@ Get quaternion from a vector.

rotation = np.eye(4)
# (x0, y0, z0) ------> (x1, y1, z1)
# x, y, z = x1 - x0, y1 - y0, z1 - z0
x, y, z = x0 - x1, y0 - y1, z0 - z1 # I don't know why but this one works
x, y, z = x1 - x0, y1 - y0, z1 - z0

# x-axis
rotation[:3, 0] = np.array([x, y, z])
# z-axis, must be (0, 0, 1) when z == 0
rotation[:3, 2] = np.array([-x * z, - y * z, x ** 2 + y ** 2])
# y-axis, calculated from x and z
rotation[:3, 1] = np.array([y, -x, 0])
rotation[:3, 1] = np.array([-y, x, 0])
q = tf_transformations.quaternion_from_matrix(rotation)
```

Expand Down

0 comments on commit 56696d6

Please sign in to comment.