Rotate sphere inside cylinder

Recommended Posts

Hi just started to use babylon js  Would like to  have some sugestions on physics animaton. I have cylinder like mesh and inside in it is small sphere. I need to animate ball so that it push to border of cylinder and moves along it in cw direction, like centrifuge. Can i do it using physics? Till now i did it using posotion changes but as i need to slow down it would be nicer with some forces. One way I thought of  is to calculate angle from center and apply impulse away from center and slighty forward but maybe there is better way.

Share on other sites

As long as the movement is not very hard to code you can do it by simply setting position, it's your choice

Share on other sites

I would like to do it with physics.  But it is not really clear how to add force so it moves along border of cylinder

Share on other sites

@Hersir use @ to let me know about reply next time. first of all are you sure you need to apply force or can a body push each other? if not consider using applyImpulse

if you need to calculate the direction propertly ask me and I will show you how to do it using rotation matrix. Sorry if I didn't understand what you meant.

Share on other sites

@wo997 Sorry for poor explanation.  What I need is a mesh that is cylinder with hole in middle. So its looks like tube, and inside is one object , sphere. This sphere should accelerate in CW direction by applying force. Sphere is pushed to border of cylinder and hits it and rolls along it in CW direction.

Share on other sites

@Hersir Consider making many jointed cuboids, can you image this arrangement? It's the only way to do it propertly, you need physics and rendering as well. Making them as one body can be a little challenge for you, I would use joints and I would place virtual cube in middle so it holds cuboids together.

Share on other sites

I think picture will describe my idea better. I want to move sphere inside "bowl like object",  using physics, I have working version for initial impulse that shoots ball and than it slowly slows down but I need to maintain speed till its ready to slow down (as slowdown need to happen on user interaction) so I need to re-add impulse in correct direction (tangential acceleration I think http://formulas.tutorvista.com/physics/tangential-acceleration-formula.html ) . But is it even possible to maintain constant speed with applyImpulse or applyForce?

Share on other sites

Yes it is possible but perhaps you may not need to use physics and instead use your won code?

Something like this:http://www.babylonjs.com/Demos/Facets/

Share on other sites

Hi guys!  Yeah, somebody else was goofing around with that, too.

Version 42 is good, too... http://www.babylonjs-playground.com/#PBVEM#42

I bet that whole playground series is full of weird things.  No 3rd party physics engines used... in those two.

There IS a physics engine version somewhere around here.  I think I saw someone put @RaananW's little physics-active car... in the bowl, too.  And his cloth mesh got dropped into the bowl, as well.

Ahh, there it is.  That's the physics engine version... with the car, and the cloth, and the ball... all in the bowl.  But, it's not working right now.  hmm.

Good fun.  Hope this helps.  Maintain perpetual motion, you say?  Helluva challenge.