Math question

Kay C Lan lan.kc.macmail at gmail.com
Fri Feb 26 12:04:07 CET 2016


On Fri, Feb 26, 2016 at 1:09 PM, Peter Bogdanoff <bogdanoff at me.com> wrote:

>
> How would one modify this to return tOffset as a smaller change when tData
> is near zero, and the opposite when tData is near the maximum?
>

If I run your handler for values of -5 to 5 I get this:

-220
-160
-100
-40
20
80
140
200
260
320
380

I think what you need is use x to the power of. ie x*x, x*x*x, or  x*x*x*x

Examples you can try in the message box below.

Note, a negative number multiplies by a negative number is a positive
number, so if you have an even number of x's you need the if (x < 0). If
there is an odd number of x's then you don't need the if.
As you can see by applying more and more multiples of x it flattens out in
the middle and is steeper at the ends.


put empty into msg
repeat with x = -5 to 5
 if ( x < 0) then
  put "-" & (12*x*x) & cr after msg
 else
  put (12*x*x) & cr after msg
  end if
end repeat

-300
-192
-108
-48
-12
0
12
48
108
192
300

put empty into msg
repeat with x = -5 to 5
 put round(2,4*x*x*x) & cr after msg
end repeat

-300
-154
-65
-19
-2
0
2
19
65
154
300

put empty into msg
repeat with x = -5 to 5
 if ( x = 0) then
  put "0" & cr after msg
 else
  if (x < 0) then
   put "-" & round(0.478*x*x*x*x) +1 & cr after msg
  else
   put round(0.478*x*x*x*x) +1 & cr after msg
  end if
 end if
end repeat


-300
-123
-40
-9
-1
0
1
9
40
123
300


More information about the use-livecode mailing list