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

Add creation.axis #255

Merged
merged 2 commits into from Nov 21, 2018
Merged

Add creation.axis #255

merged 2 commits into from Nov 21, 2018

Conversation

wkentaro
Copy link
Contributor

@wkentaro wkentaro commented Nov 20, 2018

Example

#!/usr/bin/env python

import numpy as np
import trimesh


scene = trimesh.Scene()

# plane
plane = trimesh.creation.box(extents=[1, 1, 0.01])
plane.visual.face_colors = [0.5, 0.5, 0.5, 0.5]
scene.add_geometry(plane)
scene.add_geometry(trimesh.creation.axis())

# object-1 (box)
box = trimesh.creation.box(extents=[0.3, 0.3, 0.3])
box.visual.face_colors = [0, 1., 0, 0.5]
axis = trimesh.creation.axis(origin_color=[1., 0, 0])
translation = [-0.2, 0, 0.15 + 0.01]  # box offset + plane offset
box.apply_translation(translation)
axis.apply_translation(translation)
rotation = trimesh.transformations.rotation_matrix(
    np.deg2rad(30), [0, 0, 1], point=box.centroid
)
box.apply_transform(rotation)
axis.apply_transform(rotation)
scene.add_geometry(box)
scene.add_geometry(axis)

# object-2 (cylinder)
cylinder = trimesh.creation.cylinder(radius=0.1, height=0.3)
cylinder.visual.face_colors = [0, 0, 1., 0.5]
axis = trimesh.creation.axis(origin_color=[1., 0, 0])
translation = [0.1, -0.2, 0.15 + 0.01]  # cylinder offset + plane offset
cylinder.apply_translation(translation)
axis.apply_translation(translation)
scene.add_geometry(cylinder)
scene.add_geometry(axis)

scene.show()

2018-11-21_00-37-10

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 84.362% when pulling 78ecca0 on wkentaro:axis into 30983d3 on mikedh:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 84.362% when pulling 78ecca0 on wkentaro:axis into 30983d3 on mikedh:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 84.362% when pulling 78ecca0 on wkentaro:axis into 30983d3 on mikedh:master.

@coveralls
Copy link

coveralls commented Nov 20, 2018

Coverage Status

Coverage increased (+0.03%) to 84.352% when pulling 9423266 on wkentaro:axis into 30983d3 on mikedh:master.

@mikedh
Copy link
Owner

mikedh commented Nov 20, 2018

Looks great! Could you add a docstring to axis before I merge?

Thanks!

@wkentaro
Copy link
Contributor Author

I added the docstring and and example on the top of this PR.

@mikedh mikedh merged commit c0b2d31 into mikedh:master Nov 21, 2018
@mikedh
Copy link
Owner

mikedh commented Nov 21, 2018

Awesome thanks for the PR!

@wkentaro wkentaro deleted the axis branch November 22, 2018 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants