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

Colliding particles in the box #284

Merged
merged 18 commits into from Aug 17, 2020

Conversation

nasimanousheh
Copy link
Contributor

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!

dome-collision-particles

@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #284 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Impacted Files Coverage Δ
fury/utils.py 85.86% <100.00%> (ø)

Copy link
Contributor

@skoudoro skoudoro left a 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.


##############################################################################
# In this example, the particles collide with each other and with the walls
# of the container. When the the collision happens between two particles,
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: remove one the

Comment on lines 111 to 114
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)
Copy link
Contributor

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]])


scene.add(tb)
showm.add_timer_callback(True, 50, timer_callback)
showm.start()
Copy link
Contributor

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):
Copy link
Contributor

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.

Copy link
Member

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.

@skoudoro skoudoro added this to the 0.6.1 milestone Aug 7, 2020
@skoudoro skoudoro requested a review from Nibba2018 August 7, 2020 19:21
Copy link
Member

@Nibba2018 Nibba2018 left a 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.

Comment on lines 130 to 132
tb = ui.TextBlock2D(bold=True)
scene.zoom(0.8)

# use itertools to avoid global variables
Copy link
Member

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.

Copy link
Contributor Author

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.

# Collision happens if the distance between the centars of two
# particles is less or equal to the sum of their radii
Copy link
Member

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):
Copy link
Member

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.

@skoudoro
Copy link
Contributor

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.
Thank you really much!

@pep8speaks
Copy link

pep8speaks commented Aug 13, 2020

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

@skoudoro
Copy link
Contributor

Thanks @nasimanousheh, Merging

@skoudoro skoudoro merged commit bad83ce into fury-gl:master Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants