Page 1 of 1

Mass to restrict motion in one direction

Posted: Fri Oct 13, 2017 2:12 am
by maheshkurmi
What should be that best way to restrict motion of body in particular direction only, I am thinking of two possible solutions..

1. Create new joint (kind of prismatic joint with upper limit set to infinite, other end remains fixed on ground)

2. Create new MassType having infinite mass in direction perpendicular to the allowed movement direction, but obviously mass is scalar so

How should I approach, keeping stability in mind?

I personally prefer creating new MassType, and I am ready to modify dyn4j for this.

Re: Mass to restrict motion in one direction

Posted: Fri Oct 13, 2017 8:17 pm
by William
Would the direction of allowed motion change? If so, is the change of direction controlled by user input?

I think a valid constraint (Joint) would be the most stable, but that is definitely more effort if made to fit your specific need. You could probably get away with just copying the PrismaticJoint and making a few modifications. I've also seen some talk of a body's motion being constrained to an arbitrary path. Not trivial, but could offer some neat interactions.

A new mass type is probably easier to try out. In this case you would need to consider all the places where the mass is used to make sure the logic to restrict is executed.

William

Re: Mass to restrict motion in one direction

Posted: Sun Oct 15, 2017 7:47 am
by maheshkurmi
Thanks William ..

I am trying to create a body which is allowed to move vertically or horizontally (predefined directions) .

For example if body can move in vertical direction only, no effect of forces/impulses should be experienced in horizontal direction,
BTW body is free to rotate about center.

Creating new mass type seems to be good idea. Is there something I should keep in mind before doing this?