2
$\begingroup$

Creating a door for the cabinet. I want to rotate it until it touch the base. Uptill 180 the slider (influence) works perfect 0 to 1. After increasing from 180+ value the slider (influence) does not work. I want the flap to be touch to the base. And it takes the rotation of 225. How can i rotate or make the flap touch the base.

enter image description here

Any suggestion how it works. Thanks

$\endgroup$

1 Answer 1

5
$\begingroup$

As far as I understand, a constraint defines a range of allowed values and if the value is outside of it, it snaps to the nearest boundary. Unfortunately it doesn't operate on transform properties, where you can have e.g. 1000° rotation, but on matrices using quaternions.

rotation angles differing precisely by the natural period will be encoded into identical quaternions and recovered angles will be limited to { 0 , 2 π } (in radians)

https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

This means, that for a constraint, 460° angle is the same as 100° (100°+360° = 460°). You can't therefore constrain an object to some number of rotations, after which it will no longer rotate. So if you set the constraints to -180°..180°, it is not constrained at all, because no matrix can translate to a different value in Euler rotation. If an object is at 181° rotation, it is the same as if it was at -179°. Therefore, if you want to limit your object's rotation to 150°..225° range, you have to use two constraints: 150°..180° (any higher value would also work but would really mean 180°), and then -180°..-135° - the problem is, you can't combine constraints like that, they are applied one after another. So if the rotation is 181°, after converting to quaternions and back, it is now -179°, which is below the lower limit of 150°, so it is clamped to the lower limit, unintuitively snapping from 181° to 150° instead of closer 180°:

When the next constrain is applied, it will now snap this angle to the -180°..-135° range.

The general solution is to rotate the object to exactly half its possible rotation and apply rotation to set it to 0, so that now it can move 180 degrees in either direction. In your case, knowing the constrained range is much smaller, you may feel tempted to apply the rotation at a more elegant position, e.g. -45°, since -225° + 45° is exactly -180°, but then you would run into the mentioned flipping problems when a value below -180° suddenly changes to a value below 180° and is snapped to the wrong boundary of the constrain, so remember to give yourself some safety margin.

If you don't want the flipping:

Then you just have to resign from the constraints and use a driver:

$\endgroup$
2
  • $\begingroup$ Thanks for the answer. But after adding the driver will the slider (influence) will work $\endgroup$
    – atek
    Commented Mar 10, 2021 at 2:46
  • $\begingroup$ @atek you could use a custom property to define the influence. Since the base angle is 0, you would then only need to multiply the calculation by that influence. $\endgroup$ Commented Mar 10, 2021 at 8:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .