2
$\begingroup$

Does anyone know why when I type in driver editor / scripted expression I get funny values? This is my examle:

I drive spotlight angle with an cubes translate Z value witch is limited to value between 5 and 8(limit location constraint).

So when I leave "var" alone (which is 5 value) the result is 180° instead of 5?

Does anyone knwo why and how to remap the range from 5-8 to be 1-180?

Thanks in advance!

$\endgroup$
1
$\begingroup$

I answered my self when I posted this question :D

The scripted expression is working in radians by default and is auto converted to degrees in the spotlight object. So what I did was: var - 5 and got my range just in the sweetspot. Now it goes approximately from 1 to 172 deg.

I'm not sure for the precise math behind it, but it is working for me. If you need in depth how the math is functioning, check degrees to radians conversion.

Cheers!

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ The expression to 180 would be (var-5) (shift the 0 point) *(pi/180) (convert to radians) *60 (map the range of 3 to a range of 180). This simplifiies to (var-5) * (pi/3). Slightly clobbered by the min spotlight angle being 1 degree, not 0. (You can accept your own answer) $\endgroup$ – Robin Betts Jul 24 at 11:15
  • 1
    $\begingroup$ Also worth noting Nothing is "auto converted to degrees" . Radians is the default rotation unit. For all Rotation property values. Degrees is however the default unit chosen to display rotation in the UI (in the properties scene units panel) An alternative way to convert to radians is radians(x) $\endgroup$ – batFINGER Jul 24 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.