Skip to main content
Tweeted twitter.com/#!/StackMma/status/209377947084259328
added 4 characters in body; edited title
Source Link
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

A Creating a slider that instead of setting, increases/decreases a variable

The objective:The objective: createCreate a slider that, when displaced from the center, increases-decreases the value of another variable at a rate proportional to the displacement.

So, I create a slider that automatically comes back to the center

Slider[Dynamic[var, {(var = #) &, (var = 0.) &}], {-1, 1}]

Now I want a second variable to be dynamically increased/decreased when var!=0.

My ideas are: 1* insert in the previous dynamic, something that does the updating 2* use an animator with it's speed set by var when var!=0. that updates the valueMy ideas are:

  1. insert in the previous dynamic, something that does the updating
  2. use an animator with its speed set by var when var!=0. that updates the value

Problems with 1*: how to control the speed of the updating given that I can't know for sure the intervals in which val will be updated, and UpdateIntervals sets an upper bound? Problems with 2*: how to make it work without it showing in the screen?Problems with the above:

  1. How to control the speed of the updating given that I can't know for sure the intervals in which val will be updated, and UpdateIntervals sets an upper bound?
  2. How to make it work without it showing in the screen?

Any other alternatives are welcome.

Sidenote: ideally (ideally I'd like an elegant solution).

A slider that instead of setting, increases/decreases a variable

The objective: create a slider that, when displaced from the center, increases-decreases the value of another variable at a rate proportional to the displacement.

So, I create a slider that automatically comes back to the center

Slider[Dynamic[var, {(var = #) &, (var = 0.) &}], {-1, 1}]

Now I want a second variable to be dynamically increased/decreased when var!=0.

My ideas are: 1* insert in the previous dynamic, something that does the updating 2* use an animator with it's speed set by var when var!=0. that updates the value

Problems with 1*: how to control the speed of the updating given that I can't know for sure the intervals in which val will be updated, and UpdateIntervals sets an upper bound? Problems with 2*: how to make it work without it showing in the screen?

Any other alternatives are welcome.

Sidenote: ideally I'd like an elegant solution

Creating a slider that instead of setting, increases/decreases a variable

The objective: Create a slider that, when displaced from the center, increases-decreases the value of another variable at a rate proportional to the displacement.

So, I create a slider that automatically comes back to the center

Slider[Dynamic[var, {(var = #) &, (var = 0.) &}], {-1, 1}]

Now I want a second variable to be dynamically increased/decreased when var!=0.

My ideas are:

  1. insert in the previous dynamic, something that does the updating
  2. use an animator with its speed set by var when var!=0. that updates the value

Problems with the above:

  1. How to control the speed of the updating given that I can't know for sure the intervals in which val will be updated, and UpdateIntervals sets an upper bound?
  2. How to make it work without it showing in the screen?

Any other alternatives are welcome (ideally I'd like an elegant solution).

Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190

A slider that instead of setting, increases/decreases a variable

The objective: create a slider that, when displaced from the center, increases-decreases the value of another variable at a rate proportional to the displacement.

So, I create a slider that automatically comes back to the center

Slider[Dynamic[var, {(var = #) &, (var = 0.) &}], {-1, 1}]

Now I want a second variable to be dynamically increased/decreased when var!=0.

My ideas are: 1* insert in the previous dynamic, something that does the updating 2* use an animator with it's speed set by var when var!=0. that updates the value

Problems with 1*: how to control the speed of the updating given that I can't know for sure the intervals in which val will be updated, and UpdateIntervals sets an upper bound? Problems with 2*: how to make it work without it showing in the screen?

Any other alternatives are welcome.

Sidenote: ideally I'd like an elegant solution