Need help visualizing PhysicsConstraint ANGULAR locks/limits

I need help on figuring out a way to visualize ANGULAR locks and limits on a PhysicsConstraint.

I originally thought that showing a ball in a channel or disk could represent an angularly LOCKED or LIMITED axis. Locking two axes (as shown in the front row of the playground) does lock one axis’ “ball” in place. But how do I represent a single rotationally-LOCKED axis?

(on the plus side, this problem of triple-locked axes reported by @regna seems to have been solved by @eoin, so I don’t think that that is still a problem)

This playground provides the context for this discussion. Tap to apply random forces.

Setup: All combinations of ANGULAR axis locks are represented in the playground. Each set of red/yellow boxes each have a constraint between them with the Pivot point at the center of each box. World-space X and Y axes are aligned with the red box’s Axis and PerpAxis respectively. The Red, Green, and Blue spheres are separated from the yellow box’s Pivot point and each is located along the axes defined by its Axis (red), PerpAxis (green), and the normal of those axes (blue).

In this playground, tapping the screen imparts a force to each yellow box of random direction at a random point relative to the center of mass. The red boxes are all fixed.

All constraints are locked linearly, but vary in their application of FREE or LOCKED angular degrees of freedom. Representing a FREE angular axis as “0” LOCKED as “1”, the XYZ angular locks of a constraint can be all FREE “000” or all LOCKED “111” or anywhere in between.

In the playground there are two rows of five. The leftmost are both 111 and the front rightmost is 111 (all LOCKED). The back rightmost is 000, or all axes FREE. The front center three are each locked in two axes. These front three yellow boxes spin on a single axis and are arranged in the order of their FREE axis. From left to right of these front three, the free axis is X for the first box, Y for the second, and Z for the third.

The motion of the front three makes sense, they only rotate around their FREE axis.

But notice the motion of the back center three (one LOCKED axis) relative to the back right (all axes FREE). The back right freely spins in any direction in an expected manner. The center three have a funny occasional spin in them. My uninformed guess is that this has something to do with gimbal lock. The yellow boxes can all appear to be oriented in any rotation, but getting there with one locked axis imparts a funny occasional spin.

How can I visually show an angularly LOCKED or LIMITED axis when there doesn’t appear to be a one-to-one correspondence between “locked axis” and “no angular movement”?

(Additional discussion, progress, and development are in this thread, including visualizations of LINEAR locks/limits.)

Thank you! It’ll take some time for me to parse through and maybe create some tests.

In the meantime, I found something very unexpected. In this playground, the angular locks are either LIMITED to 60 degrees or LOCKED. The back row is the “interesting” one. Left to right, they are set to

  1. All LOCKED.
  2. X LOCKED; Y and Z LIMITED 60 degrees
  3. Y LOCKED; X and Z LIMITED 60 degrees
  4. Z LOCKED; X and Y LIMITED 60 degrees
  5. X, Y and Z LIMITED 60 degrees

All look limited in exactly the same way. How is it that 5 looks limited in the same way as the others?

Numbers 2 and 5 seem to react very similarly and strangely to an imparted force. They kind of rock back and forth. I don’t think real objects do this. It’s as if there is a hidden unrestricted weighted sphere rotating (with inertia) inside and the orientation of that sphere is then copied to the yellow box and clamped to the limit values. Why?

Almost there in cases without any FREE axes and when LIMITED is less than 90 degrees.

The front row is what I’ve had in mind but the back row is not quite correct.

Currently, the channels (cylinder slices) are fixed to bodyA’s pivot point and translated to pivotB. This works for two LOCKED axes and one LIMITED (the front row). I think when there’s only one LOCKED and two LIMITED (the back row), I’ll need to adapt the cylinder axes to include pivotB rotation. I think I need to extend the flat cylinders to include the additional angular freedom, which means they’ll become a square pyramid with rounded bottom when there are two angular axes of freedom. I’m hoping this extends easily to FREE axes and to axes with limits beyond 90 degrees. We’ll see!

1 Like

You clearly became the physics wizard on the forum :wink:

Not sure about that!

Here’s an update with tall cylinders. It has given me an idea of how to do the visualization. I’ll update with that idea implemented in the next few days!

2 Likes

@eoin @Cedric

Angular limits are pretty tricky to visualize consistently, as you’ve seen.

I’m not going to claim this is the best visualization out there, but you might get some inspiration from this:

There’s a green cone displayed for two angular axes and a white arc for the remaining one. These are attached to the parent body in the constraint. The yellow and white arrows are attached to the child body and show where those axes are within the limits.

1 Like

Thank you! Seems like I’m on the right track. More debugging with my playground and really studying the results, I’ve noticed that angular locking is very specific on what it is locking in place. I first thought that the limits on “the other two axes” would both restrict an axis’ movement and that that is “symmetric” on all three axes. That doesn’t appear to be the case. Here’s what I’ve observed:

  • Y and Z restrict X
  • X restricts Y and Z
  • Y and Z do not restrict each other.

Now I have to figure out if the equivalent of a single square pyramid and arrow are sufficient to visualize that.

Getting closer! (I think)

Changed to arc camera so I can rotate around any object. Tap an object to center the camera on it.

I noticed in your video that the cone is neither a cone nor an exact square pyramid. With some combinations of limits, it appears to be rounding somewhat.

I kind of see that happening in my playground, but it my case it may be more a result of the fixed limits and the nature of the movement. There are clearly a few wrong spots in mine (the green doesn’t seem limiting in one clear case, maybe others). I hope that doesn’t mean it only seems close and I’m missing something fundamental.

And closer.

The axes that are limited vs. locked are consistent from run to run but random ranges are assigned to the limited axes. The ranges in degrees go from minimum -80 to -10 and a maximum from 10 to 80. This is a step toward any limits, but wanted to constrict to include 0 and under 180 degrees.

The back row (2 locked and one limited, far right is fully locked) is good except for the green visualization is backward along in Z axis (spin around X). Rotate only that limit/dimension by 180 degrees on Y axis. Otherwise, one improvement might be to select different axes on 3rd from left to avoid two disks.

Front row is problematic. Left to right, XYZ: L=LOCKED, R (“Range”)=LIMITED :
LRR - this one looks good
RLR - X-axis spin range on Y (green) looks backwards
RRL - Y (green) is wrong. Spin around X shown incorrectly locked. Maybe show Blue ranges?
RRR - X-axis spin range on Y (green) looks backwards

Comments and suggestions welcome.

1 Like