2D Collisions Between Circles
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I'm currently working on producing a particle-bed generator for research purposes and am stuck.
My model is supposed to mimic the Rain Model Packing Algorithm, Model III. However, I can't find any of the code for this algorithm, let alone code translatable to MatLab (I have experience in some C++, not much MatLab).
The generator must randomly drop particles (circles) with size distribution between 16-20 diameter. When two particles collide, the falling circle must rotate around the sitting circle to find the lowest y-coordinate possible, without overlapping another circle or going beyond the plot boundaries (0<x<100,0<y<100).
I don't know how to code for the collisions between circles. With squares you could check the center coordinates to figure out which direction it's biased to and move accordingly. For example, if the falling rectangle would collide with the right half of a static rectangle:
if (Rfall_center_x > Rstatic_center_x && Rfall_center_x - .5*Rfall_x_size <= Rstatic_center + .5*Rstatic_x_size)
while (Rfall_center_x - .5*Rfall_x_size <= Rstatic_center + .5*Rstatic_x_size)
Rfall_center_x++;
end
Rfall_center_y++;
end
I just can't think of a way to do this with circles, except to create some large array to store each pair of xy coordinates for each pixel on the circle's boundary and compare those.
The best guess I have into rotating a circle around another circle has to do with their center coordinates, radii, and the distance formula. But I'm really drawing a blank on how to connect those ideas logically, let alone in code.
Any help or insight into my issue is greatly appreciated! I'm fairly new to MatLab so bare with me on lack of knowledge on some syntax or functions.
-Kris
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surfaces, Volumes, and Polygons에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!