Math question

-hh hh at livecode.org
Fri Feb 26 19:05:45 EST 2016


Peter,

now I got it ...
You could use finer steps for the whole scrollbar.
The use, say between -2 and 2 these finer steps, may be steps of size 0.1,
and if the value is greater smaller than -2 or greater than 2 use a 
value rounded to the next integer or fraction of an integer.

Example:
Scrollbar setting in LC8, startvalue=-5, endvalue=5,  numberformat=0.0

The following yields

between -2 and +2 steps of 6 added to defaultSetting
between -5 and -2 steps of 30 added to defaultSetting (use n=2)

That is,
-- x is the thumbpos
-- n is the denominator in the steps 60/n ( n is one of 1,2,3,4,5,6)

function factorFromSlider n,x
  if abs(x) < 2 then
     return defaultSetting + round(60*x)
  else
    return defaultSetting + 60*round(n*x)/n  --  60 dividable by n
    --> = defaultSetting + 30*round(2*x) for n=2
  end if
end factorFromSlider


You can find an explanation for "round(n*x)/n" here
http://forums.livecode.com/viewtopic.php?p=112072#p112072

If I understood correctly, you have with the above function essentialy
what you wanted, at least I hope so.


Hermann

p.s. If using LC 5-6-7-8 "in one" you could use a scrollbar -50 to 50
with steps of 1 and

function factorFromSlider5678 n,x
  if abs(x) < 2 then
     return defaultSetting + round(6*x)
  else
    return defaultSetting + 6*round(n*x)/n
    --> = defaultSetting + 3*round(2*x) for n=2
  end if
end factorFromSlider5678

> Hermann,
> 
> Reading your last message again….
> 
> The slider is marked in absolute increments of -5, -4, -3, -2, -1, 
> 0, 1, 2, 3, 4, 5.
> 
> The user moves the thumb to a position with a corresponding output 
> of one of those numbers. That position is saved in the preferences.
> 
> I take the output from the slider and translate it to a timing 
> change. The user sees an animation synced with music notation happen 
> sooner or later on the screen. In the current linear form, that 
> change is precisely the same for each increment. But I have found 
> that most of the adjustment is needed around the zero mark, mainly 
> having to do with the speed of the user’s computer, so I need finer 
> adjustment there. 
> 
> If a user really wants to change the timing a lot, he can do so by 
> moving it to 4 or 5—it’s all subjective for each user—but the point 
> of the adjustment is to allow everyone to get it just right.
> 
> The number output from the algorithm is an offset to trigger the 
> animation earlier so after processing is done the animation looks 
> like it is in sync.
> 
>> What is your target output for example at -300, -60, 60 and 300
>> and some other values in between? What numbers do you wish to see
>> there?
> 
> 
> It seems for Windows users, zero (-300 output) makes things happen 
> too soon, and moving it to -1 (-360 output) makes it late. I could 
> change the slider to show a range of -10 to +10 to keep the visual 
> indication of exact linear change with more precision, but I’m 
> choosing to try to do it in a non-linear fashion and keep the user 
> interface simple.
> 
> Peter




More information about the use-livecode mailing list