Example Code

Collision Detection With Physics Ball Bounce

Code and Documents

Attachment

Download All

Introduction


Here it is. The first true collision detection algorithm in LabVIEW 3d picture controls Have you ever wanted to simulate dropping 200 ping pong balls?

With this VI you now can! You can even change the parameters to simulate a particle explosion to spice up any 3d environments you have created.

Ball.JPG

Be careful though, the more balls you try and drop, the more intensive the code becomes.

Why stop at balls though; Import your own model reference into the code.

Steps to Complete

To start, open real physics1.vi and simply run the VI

FP.JPG

If you want to play with the parameters of the explosion these are all held in the top level VI in the first for loop

If you want to increase/decrease the number of ball simply change the N value of the for loop

If you want to get in to the nitty gritty have a look in the subVI. In there you can change GRAVITY and bounce coefficient

Additional Notes

This VI simulates collisions of each ball with the ground but at present there is no ball-to-ball collisions. That would just be insane! (feel free to try and add it in).

When a ball has ceased movement it has a little tendency to pass through the ground a bit.


Philip
Applications Engineer
National Instruments
UK Branch

===If this fixes your problem, mark as solution!===

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors