Slider::setRotaryParameters asserts

gui

#1

Hello
I know there was already an old similar topic there but it did not mention the assert that annoys me.
In my user interface I have Pan pots and they use juce::Slider set up with setRotaryParameter(-halfPi, halfPi);
this actually works fine, I get what I want, with 90 degrees to the left for the min value, and 90 degrees to the right for the max value.
My question is simple. Could you please remove the following line in Slider::setRotaryParameters (RotaryParameters p)?
jassert (p.startAngleRadians >= 0 && p.endAngleRadians >= 0);
I don’t see why a negative values would be a problem at all… otherwise how can you implement a pan pot with this class??

Thanks

Fred - Merging Technologies


#2

The way it is used without asserting is:

setRotaryParameter (float_Pi * 3 / 2, float_Pi * 5 / 2);

In some math libraries negative values for trigonometric functions had problems. I wasn’t aware, that it works with negative numbers, but it could be problematic on other platforms.


#3

Ok thanks, it works. back to trigonometry basics :slight_smile:


#4

I think maybe the assertion is there to avoid multiple rotations or some other edge case that I don’t remember… Arguably you’re right and it could be removed, but like Daniel said, it’s also easy enough to work around :slight_smile: