Correcting angular velocities in an angular constraint

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
vanger
Posts: 13
Joined: Sun Feb 21, 2016 2:34 am

Correcting angular velocities in an angular constraint

Post by vanger »

Hello.

I'm implementing a physics engine with rigid bodies with constraints using Baltman and Radeztsky's article: http://twvideo01.ubm-us.net/o1/vault/gd ... ration.pdf

I want to speak about angle constraint between two bodies (section 8 ). The idea is as follows. We determine a relative orientation of a body B relative to a body A: we calculate a corresponding quaternion (\delta q^a_body = \bar q^a (q^b \bar q^a) q^a). Then if it does not satisfy angular constraints (which constraint imaginary components of the relative orientation quaternion \delta q^a_body s.t. sin(minXangle/2) <= \delta q^a_body.x <= sin(maxXangle/2) and so on), we divide the corresponding correction between bodies so the constraint to be satisfied.

It is also good to change angular velocities. To do this we're implementing "an angular collision" (formulas 8.11, 8.12). And here comes the question. To get satisfactory results we need to implement a collision only if angular velocities are making constraint violation worse and do nothing if angular velocities are already making situation better, aren't we? How can I determine if it is the case?

What came first into my mind is to just calculate a derivative of the \delta q^a_body and consider angular velocities "bad" if \delta q^a_body.x < sin(minXangle/2) and d/dt(\delta q^a_body.x).x < 0 (or similar to y and z). This is indeed a correct test whether angular velocities are "bad". But the result is not satisfactory because when we're implementing "an angular collision" we're changing all components of angular velocities, even that should be unchanged (e.g. when we're implementing a distance constraint -- rigid rod between particles -- we should correct only longitudinal velocities components keeping normal velocities components unchanged). How can I decide "which components of angular velocities" should I change?
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: Correcting angular velocities in an angular constraint

Post by bone »

I'm probably not fully considering your problem, but is there a solution where you can temporarily convert the quaternions to a rotation around an axis? (I'm talking about either the 4-component "axis and angle" or the similar 3-component "axis rotation" which is simply the unit axis multiplied by the angle of rotation.)

My opinion is that it would be a lot easier to isolate and debug the correct "components of angular velocity". But then again, I've never really understood quaternions. :)
vanger
Posts: 13
Joined: Sun Feb 21, 2016 2:34 am

Re: Correcting angular velocities in an angular constraint

Post by vanger »

Thanks for the answer!

If I understood you correctly, no. What I want to do is to forbid some body orientations. So there would be some allowed rotations and some forbidden. In 2d a rotation can be described by knowledge where some particular vector, (1, 0) for example, goes. So 2d rotations can be thought of as a circle. And circle can be "unfolded" to a line: we can think of a circle as a line factored bo 2 \pi. So to describe some region in the space of 2d rotations it's enougth to set limit like min_angle <= angle <= max_angle.

In 3d the space of rotations is more complicated. And even its "unfolding" (universal covering, as topologists say) is a three-dimensional sphere. Unit quaternions are just a convenient way to speak (and more importantly, do calculations) about this sphere.

When we want to constraint 3d rotations, we need to select some region of allowed rotations in the space of 3d rotations (SO(3)) or on its unfolding (unit quaternions). This is essentially what I was trying to do constraining the quaternion's components (sin(minXangle/2) <= \delta q^a_body.x <= sin(maxXangle/2), etc). Maybe it's not the best way to do it. If you know abother way, some article, please let me know. There is always a last resort to dive into Bullet source, but I hope there is some text, waiting for me :) What it the correct way to describe, lets say, a shoulder joint?

What I definitely understood is that article is outdated, and the modern way to simulate the constraints is to get velocity constraints, differentiating the constraint equations and to correct velocities (and positions too, using NGS) according to it. The Jacobian matrix will give the velocity corrections I need. But there's still an issue that angular constraint is inequality... I What are good texts about inequality constraints in real time physics simulation (besides Erin Catto's "Uderstanding Constraints" (which is great, btw, but I want some diversity)).
Post Reply