Hi! I'm making a spacecraft simulator and I'm working on adding support for mechanical gauges. In order to simplify the code, I'd call an update function where I specify the gauge and the current reading, in whatever units the gauge displays the information (e.g., feet, feet/sec, g's, etc).
In order to do that, I do the following operations in the startup phase:
- Rotate the needle to the minimum scale value and store its rotation in a quaternion.
- Rotate the needle to the maximum scale value and store its rotation in a quaternion.
Then, during the simulation, the UpdateNeedle function converts the needle's current reading to an interpolated value between 0 and 1 and calls the Quaternion.Slerp method in order to rotate it to the appropriate position. The function works fine for instruments whose scale doesn't span more than 180 (see the "Oxygen" gauge) but I'm having problems for bigger scales (see the "Altitude" gauge).

More specifically, the "Altitude" gauge interpolates in the yellow area between the blue and red squares, which is clearly not what I want. How can I make the rotation using the other part of the scale?
Thanks in advance for your help!
--Nacho