Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Point3d.transform_with #191

Merged
merged 1 commit into from
Sep 6, 2024
Merged

Fix Point3d.transform_with #191

merged 1 commit into from
Sep 6, 2024

Conversation

pascalzauberzeug
Copy link
Contributor

Both the dot product and the translation vector in Point3d.transform_with are 2D but need to be 1D for Point3d.from_tuple, which causes the coordinates to be np.arrays and not floats.

return Point3d.from_tuple(np.dot(pose.rotation.R, self.array) + pose.translation_vector)

import numpy as np
from rosys.geometry import Point3d, Pose3d, Rotation

point = Point3d(x=0.015, y=0.135, z=0.357)
pose = Pose3d(x=0.2965439264325891, y=-0.004233199581623145, z=0.3609662018089546,
              rotation=Rotation.from_euler(-138.1, -1.3, 89.9))

# works
new_point = Point3d.from_tuple((np.dot(pose.rotation.R, point.array) + pose.translation_vector).flatten())
print(new_point)
# Point3d(0.341, -0.366, 0.475)

# does not work
new_point = Point3d.from_tuple((np.dot(pose.rotation.R, point.array) + pose.translation_vector))
print(new_point)
# TypeError: unsupported format string passed to numpy.ndarray.__format__

@pascalzauberzeug pascalzauberzeug added the bug Something isn't working label Sep 6, 2024
@codingpaula codingpaula added this to the 0.16.1 milestone Sep 6, 2024
Copy link
Contributor

@codingpaula codingpaula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top!

@codingpaula codingpaula merged commit 5e8d34b into main Sep 6, 2024
6 of 7 checks passed
@codingpaula codingpaula deleted the fix_transform_with branch September 6, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants