Sand Collision?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Kingfrankbob
 
Posts: 37
Joined: Thu Jul 19, 2018 7:11 pm

Sand Collision?

Post by Kingfrankbob »

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.

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

Re: Sand Collision?

Post by rpiloverbd »

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

User avatar
Kingfrankbob
 
Posts: 37
Joined: Thu Jul 19, 2018 7:11 pm

Re: Sand Collision?

Post by Kingfrankbob »

Ah thanks, I just missed the documentation of obstacles!

For reference:

Code: Select all

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”