# I need help with angular constraints in 2d

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've been experimenting a bit with constraints between particles ( stick constraints mostly ). I would like to make angular constraints now. However they seem to be too complex for me : I have three particles P1, P2 and P3 the constraint I want is: angle( P1-P2 ) - angle( P3-P2 ) < x If I understand correctly the center of mass of the three particles should remain in the same place in space after the constrain has been applied, so this constrain also has to be satisfied: P1+P2+P3/3 = P1c+P2c+P3c/3 Being Pi the position of each particle before applying the constrain and Pic the position after. ( For simplicity all of the particles have the same mass ) I dont want to restrict the distance between the particles at all ( if I move P3 in a way that doesnt disturb the constrain the other particles shouldnt be affected ) Anyway... I am clueless on how to correct each particle. What I would like is some function that corrects them in a single step ( like it is done with sticks ) though I am not sure if its possible or reasonable to do that. I would be grateful if someone could give me some ideas.

##### Share on other sites
Quote:
 I dont want to restrict the distance between the particles at all ( if I move P3 in a way that doesnt disturb the constrain the other particles shouldnt be affected )

I'm not sure why you can't use a maximum distance constraint between P1 and P3.
For instance, state that the distance between P1 and P3 can never be greater than 100. Unless the length of P1-P2 or P3-P2 isn't constant...

Hmm, I haven't tried this but...

If you determine that the angle is too great, find the vector P3-P1, and then adjust P3, P1 along this line. If you know the desired angle, P2 is fixed, and you know the ratio of the two remaining angles is the same you could probably find some math in that vein.

Alternatively, take P3-P2 and rotate it x degrees from P1-P2.

Sorry for the lack of concrete advice, just throwing some ideas out there.

- Xavier

##### Share on other sites
None of the three particles is fixed, so I can not just rotate P3 and P1 around P2, since P2 will probably move aswell ( unless the invmass of P2 is 0 )

##### Share on other sites
Please can you redefine the problem as you cannot define an angle as P1-P2, there is nothing for the angle to be between.

Would you mean L1-L2 where L1 = P1-O(rigin) and L2 = P2-O ?

A diagram would help :)

Here you go:

##### Share on other sites
I assume the 3 particules have the same mass (is it true ?)
Then i would go like this :

- calculate A the angle <P1P2P3>
- if A<x then do nothing (easy :) )
- else, calculate Ac=A-x the correction angle you need to apply
- calculate C the center of P1 P2 P3
- rotate P1 around P2 by the angle A1c and rotate P3 around P2 by the angle A2c where:

- A1c+A2c=Ac
- but one equation is not enough to determine A1c and A2c, so add another contraint which can be A1c/L2=A2c/L1 where L1 is the distance P1P2 and L2 the distance P2P3. This way, the shorter leg will be moved by a higher angle (in my opinion this should minimize displacement)

- after P1 and P3 are moved, calculate Cc, the center of your new particules
- then translate all the particule by the vector CcC

##### Share on other sites
Yay, thanks a lot David! This seems like the solution I was looking for.
Actually.. there is one small thing I will change for correctness sake and that is that I will project P1 and P3 into their correction angles instead of rotating them. This minimizes more the displacement and makes more sense since I am not trying to constrain the distances only the angle.

Thanks again! I will report after I have done some tests with it ;)

Edit:
Argh.. I just found a counter example, it seems the method is not flawless after all.

The counter example is, if P1 and P3 have infinite and P2 is between them, the constraint angle is still 90º. Then or P1 and P3 will move, even though they have infinite mass, or P2 wont move.

[Edited by - basara on May 18, 2006 1:43:28 PM]

##### Share on other sites
Quote:
 Original post by basaraArgh.. I just found a counter example, it seems the method is not flawless after all.The counter example is, if P1 and P3 have infinite and P2 is between them, the constraint angle is still 90º. Then or P1 and P3 will move, even though they have infinite mass, or P2 wont move.

hmm, you mean the particules can have different masses ?
In that case it seems very difficult to solve analytically :/
Even the assumption that the barycenter will stay at the same place is not true in your example.

after thinking about it, the assumption that the barycenter will stay at the same place is still true in your example, of course, as P1 and P3 have infinite mass, the barycenter is always in the middle of P1P3, so it doesn't move.
But still, your problem seems very hard. Maybe your best bet would be to assume that the displacements will be very small, so that you can linearize the equations...
good luck ;-)

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999985
×