Question: How to restrict "deflection" of joined bodies
See original GitHub issueI have the following scenario (also see image):
- 2
SimulationBody
: 1 with “normal” mass (Body B) and the other one is fixed (Body A) - They are joined together via
RopeJoint
so that only a specific area is reachable by Body B
Goal:
- Body B should be only allowed to take a position in the upper half circle around Body A
Drawing:
Question
Is there a Joint already available to accomplish such a behaviour? (AngleLimitation in combination with a RopeJoint
)?
My ideas
RevoluteJoint
: But this is not applicable in combination with aRopeJoint
(at least I couldn’t make it run)- Definition of an
angle listener
which observes the angle of theRopeJoint
after every simulation step --> so far I use the following “calculations” which generates results, which I didn’t expect (from the angle value point of view.
/**
* Method call AFTER a SimulationStep is done.
*/
@Override
public void end(Step step, World world)
{
// Get the SimulationBodies attached to the Joint
SimulationBody bodyA = (SimulationBody) this.observedJoint.getBody1();
SimulationBody bodyB = (SimulationBody) this.observedJoint.getBody2();
// Check for JointType
if(this.observedJoint instanceof RopeJoint)
{
// Get the AnchorPoints (current)
Vector2 anchorA = this.observedJoint.getAnchor1();
Vector2 anchorB = this.observedJoint.getAnchor2();
// Calculate the angle in rad
double currentAngle = anchorA.getAngleBetween(anchorB);
System.out.println("Current Anchor-Angle = " + currentAngle + " (rad) | " + Math.toDegrees(currentAngle) + " (deg).");
// Check if current distance is withhin the maxLength
if(currentAngle < 0)
{
bodyB.setLinearVelocity(new Vector2(0.0, 0.0));
}
else
{
// Do nothing
}
}
}
There I get values like
- Current Anchor-Angle = -0.0014672951941631651 (rad) | -0.08406982192537803 (deg).
- Current Anchor-Angle = 0.16941188466027896 (rad) | 9.706585990391076 (deg).
- Current Anchor-Angle = 0.007939302723439068 (rad) | 0.4548885383297788 (deg).
But I expected something in-between 0 - 180 deg. Maybe I misunderstood the concept of angle calculation…
- Definition of a “repulsion field” (Not tested so far -> I think this is the most “complex” method -> Listener definition and sensor modelling and so on)
But somehow I don’t think that these ideas are target-oriented and easy to maintain.
Is there something I am missing in your library to get the requiered behaviour?
Thank you very much in advance for other ideas or some hints. 😃
I can provide my “test-case” if necessary
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
1.7: Deflection of Beams- Geometric Methods
The serviceability requirements limit the maximum deflection that is allowed in a structural element subjected to external loading.
Read more >Structural deflections : a literature and state-of-the-art survey
Dynamic system deflection is controlled to limit: dynamic whole body vibration audible perception of motion dynamic visual perception to motion.
Read more >Mechanics of Materials Chapter 6 Deflection of Beams
For this reason, building codes limit the maximum deflection of a beam to about 1/360 th of its spans. double- integration method is...
Read more >Deflection of Beams - Formula, Methods, Questions
It is very important to limit the deflection of beams as too much deflection might cause damage to other parts of the structures....
Read more >Structural Beam Stress and Deflection for Non-Engineers
Block and tackle mounted on the beam properly that we are going to use to lift the engine (rated far above 300 lbs)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If C needs to move with A, things are definitely more complicated. An alternative approach would be to add C as a fixture on the A body and mark it as a sensor. Senors report collisions, but are not resolved. If a collision between the sensor occurs you perform your logic to enforce the constraint.
The
Vector2.getAngleBetween(Vector2)
method is used to find the angle between two vectors. You are passing two points - the anchor points of theAngleJoint
in this case. These are the world space center’s of the bodies A and B.The output of the
Vector2.getAngleBetween(Vector2)
method when supplied with points really means that you are getting the angle between the the vectors O->A and O->B where O is the origin. This is because while Vectors and Points use the same Vector2 class in the library, they are two different concepts. In my example below, the green and orange lines represent the O->A and O->B vectors. The angle between the vectors in my example is ~85 degrees.What you really want is the angle between the x-axis of A with the vector from anchorA to anchorB (the purple and black dashed lines in my example). In other words:
Thany you very much for the help, the very good explanations and your suggestions 😃
This is also a very good hit I will keep in mind.