Due to high demand, expect some shipping delays at this time - orders may not ship for up to 2-3 business days.
0

Sand Collision?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Sand Collision?

by Kingfrankbob on Tue Jan 25, 2022 9:15 pm

I've been looking at the sand collision code from the Adafruit PixelDust library Github, and I don't fully understand where it detects a collision for each of the particles on the sine waves. I also don't know if this is the right post place.

The GitHub: https://github.com/adafruit/Adafruit_Pi ... spberry_pi. Its c, and py.

Kingfrankbob
 
Posts: 27
Joined: Thu Jul 19, 2018 7:11 pm

Re: Sand Collision?

by rpiloverbd on Wed Jan 26, 2022 12:00 pm

Hello, here is more detailed documentation. Have you already seen this?
https://github.com/adafruit/Adafruit_PixelDust

rpiloverbd
 
Posts: 198
Joined: Mon Nov 29, 2021 8:13 am

Re: Sand Collision?

by Kingfrankbob on Wed Jan 26, 2022 7:18 pm

Ah thanks, I just missed the documentation of obstacles!

For reference:
Code: Select all | TOGGLE FULL SIZE
Library Method Used
The Pixel Dust library allows pixels on the grid to be defined as obstacles. The 'dust' pixels (or grains as they are referred to from this point forward) are unable to occupy these potions and will collide and bounce off of them. These pixels are defined using the setPixel() method. This method takes a position in the form of x (horizontal position or column, 0 to width - 1) and y (vertical position or row, 0 to height - 1)as shown below.

sand->setPixel(x, y);
When displaying an image on the matrix, it stands to reason that we do not want the grains to occupy the same space and we would like them to bounce off the image. Drawing the image is not enough, we need to identify each pixel occupied by the as an obstacle. Since we only need to call the setPixel() method when we want to define the obstacle we are either calling it or NOT calling indicating we have a binary outcome. Thus, we need only a bit to represent each obstacle. If the bit is 1 then call setPixel() for the corresponding position, if it is 0 don't call it.

Kingfrankbob
 
Posts: 27
Joined: Thu Jul 19, 2018 7:11 pm

Please be positive and constructive with your questions and comments.