News:

Interested in some really terrific mobile apps? Visit www.turboapps.com for details.

Main Menu
TurboCAD 2026 Platinum box
Now available

TurboCAD 2026.2

The latest update for TurboCAD 2026. It installs over any 2026 build and keeps your activation, drawings and settings. Get it from the Start Page or Help > Check for Update.

Script or PPM for Randomized Spheres

Started by Don Cheke, November 21, 2020, 06:00:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Don Cheke

Any of you guys that know how to make scripts that will run in TC know how to fill an area with randomized 25mm spheres, like gumballs in a globe?
Don Cheke
My Blog: One Man's Meanderings

Torfinn

The random part will be a problem Don, ppm is a pretty stupid thing, it is exactly like we write it and never change from that pattern, dimensions can be changed, but it still follow the same pattern, it's possible to write several patterns to switch between, but still a pattern
And by that it will be difficult to make it look natural, as we never know how the balls will move if we take out 1 or 3 from the tube in real life either.
And when we fill a tube with balls, we have no ide'a about how they will place them self inside the tube, some will touch the glass, some will not.
But a interesting issue.

Torfinn
V20, V21, 2015 > 2024  Platinum
Deluxe 2015/ 16/ 19
RedSDK enabled
Windows 10 Home Premium (20H2/ 19042.1083) 64 bit, 32 GB
NVIDIA Geforce GTX 780m, 1 GB

Henry Hubich

Wow. The gumballs wouldn't be completely randomized; they'd be packed somehow, each ball in contact with some number of neighbors. I suspect that this is a genuinely difficult problem, especially given the diameter of your particular globe.

Henry H

nikkipollard

#3
Definitely not a ppm project.
But It sounds like a simple computer game.
There must be an easy algorithm out there would be able to quickly find a likely position of each gumball.
Once you have that it should be easy to use the SDK or Ruby to draw those balls and assign a "random." colour to them
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Don Cheke

Thanks Torfinn, Henry and Nikki for letting me know your thoughts.

I had asked on a couple other forms and it looks like it can be done relatively easy in SolidWorks with a motion study.
Don Cheke
My Blog: One Man's Meanderings

DonCW

Quote from: Don Cheke on November 22, 2020, 02:08:59 AM
Thanks Torfinn, Henry and Nikki for letting me know your thoughts.

I had asked on a couple other forms and it looks like it can be done relatively easy in SolidWorks with a motion study.

It looks easy with the right software and know how. When do you sleep Don.
DonCW
2020 Platinum
2018 Platinum
2017 Pro with Light Works Plug in



Windows 10
There's so much to learn and not much time left to learn it.

murray dickinson

#6
The spheres' distribution is a "kissing number" problem as a nesting problem rather than randomising.  I love that term.  I read somewhere it's been worked out to the 11th dimension, the concept of which does my head in. 

Alvin Gregorio

If the gumballs were really slick, and the gumball machine container was shaken/agitated a certain number of times in a certain way with a certain amount of force, I would assume and expect that a bottom layer would occur that would be the only one possible layout of the bottom layer.

Then, with continuation of that same shaking/agitation movement, the second layer would develop into what the only one possible scenario would be.
And so on.

I suspect what you did Don when you modeled this gumball machine (full of gumballs) would be the result.  (being familiar with how exacting you are, I suspect you went through the efforts of distributing the gumballs in your model such as above)
Alvin Gregorio
TurboCAD: v2024_Plat (31.0.77.1); v2022_Plat; v2020_Plat; v2019_DL; v20.2_PP
Lenovo Thinkpad P20Y laptop; Windows 11 Pro; i7-11800H 2.30GHz, 8-core; 32GB RAM; NVIDIA T1200
3D_Printer: Ender-3 S1 (NOT Pro)

Don Cheke

Quote from: DonCW on November 22, 2020, 03:20:59 AM
It looks easy with the right software and know how. When do you sleep Don.

Very true. Folks on the MoI forum are suggesting SketchUp with the MSPhysics add-on.

As for sleep, I am sleeping more than ever, and sometimes when I wake up at 4:00am to pee, I get sidetracked to my computer. Too much information? :-)
Don Cheke
My Blog: One Man's Meanderings

Don Cheke

Quote from: murray dickinson on November 22, 2020, 03:56:35 AM
The spheres' distribution is a "kissing number" problem as a nesting problem rather than randomising.  I love that term.  I read somewhere it's been worked out to the 11th dimension, the concept of which does my head in. 
Sometimes, my wife accuses me of making up words, which is true, so I had to look up Randomize to make sure it was real. Turns out it is. Whew! :-)
Don Cheke
My Blog: One Man's Meanderings

Don Cheke

Quote from: Alvin Gregorio on November 22, 2020, 04:51:59 AM
If the gumballs were really slick, and the gumball machine container was shaken/agitated a certain number of times in a certain way with a certain amount of force, I would assume and expect that a bottom layer would occur that would be the only one possible layout of the bottom layer.

Then, with continuation of that same shaking/agitation movement, the second layer would develop into what the only one possible scenario would be.
And so on.

I suspect what you did Don when you modeled this gumball machine (full of gumballs) would be the result.  (being familiar with how exacting you are, I suspect you went through the efforts of distributing the gumballs in your model such as above)

Thanks for your vote of confidence Alvin. I am not sure your conclusion is right though. If it were a flat bottom globe, I could understand your thinking - the whole layer would be flat, but the color pattern could change as this is a gravity motion study and the balls will bounce around when landing.
Don Cheke
My Blog: One Man's Meanderings

Alvin Gregorio

Quote from: Don Cheke on November 22, 2020, 09:02:47 AM
...

Thanks for your vote of confidence Alvin. I am not sure your conclusion is right though. If it were a flat bottom globe, I could understand your thinking - the whole layer would be flat, but the color pattern could change as this is a gravity motion study and the balls will bounce around when landing.

Yep, that makes sense.
Keep us posted as to what your motion studies expose.
Alvin Gregorio
TurboCAD: v2024_Plat (31.0.77.1); v2022_Plat; v2020_Plat; v2019_DL; v20.2_PP
Lenovo Thinkpad P20Y laptop; Windows 11 Pro; i7-11800H 2.30GHz, 8-core; 32GB RAM; NVIDIA T1200
3D_Printer: Ender-3 S1 (NOT Pro)

Andy H

To program something like that in TC would be pretty difficult.  If it was just balls falling into a container in a very predictable manner with random different colours, that would be reasonably easy with just key frames, . But randomness of the balls,  That's tough because AL doesn't have any physics functions.

One would need to code separately for Gravity.  Density and  Energy absorption (which affects how a second ball will bounce as it strikes the first one),  collision with each other, Collision with the container.  Ball movement. Deflection (causing the first ball to move, when hit by a second ball).  You would probably use an array to hole the balls, but will probably need polar coordinates, as when a balll rolls over another ball, it isn't in a straight line, (plus rotation).

Blender has a physics engine, but I've never used it.


Henry Hubich

Even if the dynamics of the problem is neglected, it's far from trivial. For example, find a place to put the green ball...

Henry H

Torfinn

If you shake it there will be a place for the green ball, but where will the green ball end if the tube's dia is just a tad to small compered to the dia of x numbers of balls, where will it then end, near the edge, in between 4 others or maybe the four others don't touch each other, what level will it then be in :)

Torfinn
V20, V21, 2015 > 2024  Platinum
Deluxe 2015/ 16/ 19
RedSDK enabled
Windows 10 Home Premium (20H2/ 19042.1083) 64 bit, 32 GB
NVIDIA Geforce GTX 780m, 1 GB

Don Cheke

I just wanted to say thanks again. I did end up doing it in SolidWorks. Linked is a very low res animation.

http://www.textualcreations.ca/Videos/Bumball%20Machine%20Animation%20LowRes.mp4
Don Cheke
My Blog: One Man's Meanderings

Henry Hubich

Quote from: Don Cheke on November 22, 2020, 02:18:09 PM
I just wanted to say thanks again. I did end up doing it in SolidWorks. Linked is a very low res animation.

http://www.textualcreations.ca/Videos/Bumball%20Machine%20Animation%20LowRes.mp4

That is a fantastic piece of software.

Henry H

Torfinn

Thanks Don, that look dang nice.

Torfinn
V20, V21, 2015 > 2024  Platinum
Deluxe 2015/ 16/ 19
RedSDK enabled
Windows 10 Home Premium (20H2/ 19042.1083) 64 bit, 32 GB
NVIDIA Geforce GTX 780m, 1 GB

Henry Hubich

Quote from: Torfinn on November 22, 2020, 11:12:59 AM
If you shake it there will be a place for the green ball, but where will the green ball end if the tube's dia is just a tad to small compered to the dia of x numbers of balls, where will it then end, near the edge, in between 4 others or maybe the four others don't touch each other, what level will it then be in :)

Torfinn

Yup, Even if you decide to set it on the three yellow balls (for example), it'll still take a bit of work to find its location so that it is just tangent to the three.

Henry H

nikkipollard

Yip Way out of my capability zone.
I googled packing spheres algorithms - I got lost at the introduction
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h