Clamping angles?

I’m a little confused on how clamp angle works.

The following returns 180 (but 8 is clearly in the interval):

The following returns 0 (but 8 is clearly in the interval):

This returns 179:

image

It seems that to make this work you have to reduce the available angle interval, so this works (prints 8):

Is this expected? I realize that the whole purpose of the method is to clamp an angle, but you might want to use this method and then allow the min&max defined to full spectrum based on some settings.

Thanks,
r.

1 Like

The node description is not very clear. The min and max are both supposed to be positive.

Thanks for your input. The -180 to +179.9 interval works, though… So this has to limit the angles, correct?

Well, you can see it doesn’t work like that :wink:

Notice the mouseover

I don’t think anybody could consider a negative angle as ‘sweeping clockwise’.

Also, why not just use ‘clamp float’, then you defintely can use any pair of numbers you want :smiley:

1 Like

Ok, thanks for your time.

1 Like

Not really:

This means that the minimum value should be less than the maximum (and this should be obvious) but you can definitely use negative values in the clamp angle node

3 Likes

This doesn’t work because +180 and 180 are the same angle value, the same happens with 0 and 360. So 8 is clearly NOT in the interval because the interval is 0 degrees wide😅

This example really doesn’t make sense to me, this interval is 3 degrees wide (179, 180 and 181), so it will be clamped to the closest value to 8, 179 indeed. (try clamping a value bigger than 181 and less than 360 and it will return 181 because it’s the closest value)

This is the only correct example, because you are using an interval of 259.9 degrees, it would have worked even with 0 and 359.9 (but it doesn’t really make sense to clamp an angle to a 360 degrees interval, because 560 for example is already converted to 200 automatically if you input it in a rotator value).

7 Likes

I was of course going off route to see why the original -180to +180 example didn’t work, I didn’t expect the other examples to work, rather, see what would happen.

It is a pity that this method doesn’t allow to be used with the full angle spectre, because then it cannot be used with a setting that would decide not to clamp it.

Thank you for your time @Ares9323! Super explanation.

Best,
r.

1 Like

If you want to do that just use the regular clamp node!

2 Likes

I don’t understand why this clamp angle node exists actually…

I used it today in a project, it’s useful because the regular clamp node doesn’t behave in the same mode:

If i input 690 in a -20 / +20 ClampAngle it would return -20 (because 690 is -30), the regular clamp with the same values would return +20

3 Likes

It’s ironic that Epic obviously though about this node, but totally missed the relative rotation problem ( ie, 180 suddenly becomes -180 ).

If by regular you mean the float clamp, then that method does not consider the fact that the data are angles. That’s the whole purpose.

For instance, if you clamp 359 between -20 and +20 you will get +20 with float clamping, but 359 (or maybe -1) with angle clamping.