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
Colliding particles in the box #284
Conversation
Codecov Report
@@ Coverage Diff @@
## master #284 +/- ##
=======================================
Coverage 88.84% 88.84%
=======================================
Files 19 19
Lines 4974 4974
Branches 645 645
=======================================
Hits 4419 4419
Misses 390 390
Partials 165 165
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you really much @nasimanousheh for this nice tutorial!
See below some comments. I think this PR should be merged after #283 et #282.
docs/examples/collision-particles.py
Outdated
|
||
############################################################################## | ||
# In this example, the particles collide with each other and with the walls | ||
# of the container. When the the collision happens between two particles, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: remove one the
docs/examples/collision-particles.py
Outdated
box_colors = np.array([[255, 255, 255]]) | ||
box_actor = actor.box(box_centers, box_directions, box_colors, | ||
scale=(box_lx, box_ly, box_lz)) | ||
utils.opacity(box_actor, 0.2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part will change as soon as #283 is merged. It fixed the bug you reported and you can do
box_colors = np.array([[1, 1, 1, 0.2]])
docs/examples/collision-particles.py
Outdated
|
||
scene.add(tb) | ||
showm.add_timer_callback(True, 50, timer_callback) | ||
showm.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation can not be generated. You will need to add
interactive = False
if interactive:
showm.start()
fury/utils.py
Outdated
@@ -1073,3 +1073,21 @@ def get_bounds(actor): | |||
|
|||
""" | |||
return actor.GetMapper().GetInput().GetBounds() | |||
|
|||
|
|||
def opacity(actor, opacity_level=0.5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it is needed. Otherwise, this function needs a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It will be beneficial if we can set the opacity of individual objects instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @nasimanousheh , Thank you for this wonderful Tutorial. Are you planning to implement the same example using a pybullet? We can compare the performances between the two. It will also help us in fluid simulations.
Apart from that the tutorial LGTM.
docs/examples/collision-particles.py
Outdated
tb = ui.TextBlock2D(bold=True) | ||
scene.zoom(0.8) | ||
|
||
# use itertools to avoid global variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about replacing it with an fps counter? Later we can compare the performance with a physics engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Nibba2018! This is very simple example to show the collisions. I didn't apply mass, energy or forces to keep it simple. Definitely we will use your API for bullet in more advanced simulations. I wanted to have a very simple system with numpy for educational purposes.
docs/examples/collision-particles.py
Outdated
# Collision happens if the distance between the centars of two | ||
# particles is less or equal to the sum of their radii |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo centers
fury/utils.py
Outdated
@@ -1073,3 +1073,21 @@ def get_bounds(actor): | |||
|
|||
""" | |||
return actor.GetMapper().GetInput().GetBounds() | |||
|
|||
|
|||
def opacity(actor, opacity_level=0.5): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It will be beneficial if we can set the opacity of individual objects instead.
Hi @nasimanousheh, I just want to let you know that I plan to do a release this weekend. It will be great if you find time to fix some of the issues. |
c72d75f
to
53e2d70
Compare
Hello @nasimanousheh! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-08-13 18:55:07 UTC |
Thanks @nasimanousheh, Merging |
Hello,
This example shows a random movement of the particles in a box using FURY. The particles collide with each other and with the walls of the box. As you see in the gif file, the particle with less velocity changes its color and gets the same color as the particle with higher velocity.
Thank you!