Newton's Cradle
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Newton's Cradle
I am probably missing something obvious, but how would one go about setting up something similar to a Newton's Cradle effect? Where one object collides with another, and transfers it's momentum and stops moving itself. None of the changes I have tried have provided quite the effect I'm going for, the colliding object is maintaining most of it's velocity.
Re: Newton's Cradle
The Newton's Cradle momentum transfer requires that the objects undergo elastic collision. In elastic collision, the magnitude of relative velocity is about the same as it was before the collision. In inelastic collision, the objects have a relative velocity near zero (they are just sliding along with each other). So, ensure that the interaction properties between the entities has a bounciness of 1 (or close to it).
Note that you don't have to set the bounciness of all the objects to 1 for this to work. Instead, it is possible to assign a specific material-material relationship using the MaterialManager (requires the development fork version to work properly: http://bepuphysics.codeplex.com/SourceC ... evelopment). Note that entities can share materials.
To get a proper result, the masses should be identical.
Finally, the objects must not be in contact. They can be very close, but if there exists a contact constraint between the objects, the momentum transfer will not work quite as expected due to a quirk of the solving method.
Note that you don't have to set the bounciness of all the objects to 1 for this to work. Instead, it is possible to assign a specific material-material relationship using the MaterialManager (requires the development fork version to work properly: http://bepuphysics.codeplex.com/SourceC ... evelopment). Note that entities can share materials.
To get a proper result, the masses should be identical.
Finally, the objects must not be in contact. They can be very close, but if there exists a contact constraint between the objects, the momentum transfer will not work quite as expected due to a quirk of the solving method.
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Re: Newton's Cradle
That .... was incredibly easy. Not only that, but now I have tons of great ideas on what to do with the MaterialManager!
Thanks a ton!!
Thanks a ton!!
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Re: Newton's Cradle
Is there a way to prevent the objects from flipping up when they collide though?
Re: Newton's Cradle
That depends on the context. There's one sure fire way to stop them from flipping- set the LocalInertiaTensorInverse to all zeroes, or only one or two of the rows. That gives them infinite rotational inertia, so nothing can make them rotate around the zeroed-out axes. Obviously that may cause some unwanted side effects, but I'd need more information to create a more targeted solution.
Modifying the inertia without going all the way to infinities might work too. Scaling a row down will increases the inertia around that axis.
Modifying the inertia without going all the way to infinities might work too. Scaling a row down will increases the inertia around that axis.
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Re: Newton's Cradle
Two cylinders colliding with each other on a flat surface. When they collide sometimes (but not all the time) they flip over.
I don't want to completely disable rotational inertia on them though.
I don't want to completely disable rotational inertia on them though.
Re: Newton's Cradle
Completely eliminating that will be difficult. The incremental manifold creates a single contact point per frame. If that is at the very bottom or top of the cylinder, it will impart a significant angular velocity to the objects and could cause a flip. Decreasing the time step duration will lessen the effect. Using shapes which have a special case that generates a full manifold, like box-box, will also mostly avoid the issue.Two cylinders colliding with each other on a flat surface. When they collide sometimes (but not all the time) they flip over.
Changing the dimensions of the cylinders or modifying the inertia tensor without completely disabling rotation could help mitigate it, though.
It could also be something else, though I'd probably need a video to make the distinction.
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Re: Newton's Cradle
I have the time step ( 90 hz ) about as low as the frame rate will support.
What shape would you recommend I use instead of a Cylinder?
What shape would you recommend I use instead of a Cylinder?
Re: Newton's Cradle
Judging by the way it behaves, simply changing it to another shape probably won't help much. Using Boxes instead would help a little bit sometimes, but it couldn't completely eliminate the issue because it's still possible for the box to generate a contact manifold on impact which doesn't evenly transmit momentum. In fact, in some scenarios, doing so wouldn't even be the physically correct option.
I would recommend playing around with the LocalInertiaTensorInverse a bit more, and possibly thinning the the shape vertically so that impact points above or below center can't generate as much angular momentum. Here's an example of how thinning could help: Due to the inertia tensor and smaller impact offset, the thinner shapes generate very little angular momentum compared to the fatter objects.
Getting too thin will cause other problems. Also note that cylinders use internal margins in v0.16.0, which means that instead of the collision margin expanding outward beyond the shape, it actually is built into the dimensions. If the cylinder height is set to less than 2 times the collision margin, or the radius is set to less than the margin, the shape will be partially inverted.
Scaling down the inverse will result in a rotationally 'heavy' appearance, but you can scale individual rows to see if you can improve the behavior a bit. Scaling upwards makes it rotationally 'lighter,' which may help landings from ramps appear more natural.
I would recommend playing around with the LocalInertiaTensorInverse a bit more, and possibly thinning the the shape vertically so that impact points above or below center can't generate as much angular momentum. Here's an example of how thinning could help: Due to the inertia tensor and smaller impact offset, the thinner shapes generate very little angular momentum compared to the fatter objects.
Getting too thin will cause other problems. Also note that cylinders use internal margins in v0.16.0, which means that instead of the collision margin expanding outward beyond the shape, it actually is built into the dimensions. If the cylinder height is set to less than 2 times the collision margin, or the radius is set to less than the margin, the shape will be partially inverted.
Scaling down the inverse will result in a rotationally 'heavy' appearance, but you can scale individual rows to see if you can improve the behavior a bit. Scaling upwards makes it rotationally 'lighter,' which may help landings from ramps appear more natural.
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Re: Newton's Cradle
Would it be possible to move the impact point when a collision is detected based on which objects are colliding?
Re: Newton's Cradle
Technically, yes. The immediate version (present tense) of the contact created or pair updated events would let you modify the contact objects directly. Care would need to be taken not to move the contact when it shouldn't be moved, or else collisions would behave very weirdly.
-
- Posts: 30
- Joined: Mon Apr 25, 2011 6:07 pm
Re: Newton's Cradle
Ok, so I think we settled on a solution I'm happy with now.
In addition to tuning the Inertia, I created a SingleEntityAngularMotor to push the objects back to their default orientation. It still allows for some rotation, but ultimately the objects end up sitting flat.
In addition to tuning the Inertia, I created a SingleEntityAngularMotor to push the objects back to their default orientation. It still allows for some rotation, but ultimately the objects end up sitting flat.