Dependencies of wave components
Dave_S
Is there a way to set the components of a wave as dependent on global variables?
What I'm after (I think) would look like:
Variable /G comp1 = 5, comp2 = 4
Make /N=2 Junk
SetFormula junk "{comp1, comp2}"
Make /N=2 Junk
SetFormula junk "{comp1, comp2}"
This would be quite handy, say, in interacting with a 2D Gaussian:
Make coeffs = {0, 4, 2, 1, 1, 4, 0}
Make /N=(100,100) fdata
SetScale /I x -5, 5, fdata; SetScale /I y -5, 5, fdata
SetFormula fdata "Gauss2D(coeffs, x, y)"
Variable /G x_offset = 2
Display; AppendImage /L/B fdata
ControlBar 35
SetVariable x_offset_ctl, value=x_offset, fsize=12, pos={35, 10}, size={120, 15}
Make /N=(100,100) fdata
SetScale /I x -5, 5, fdata; SetScale /I y -5, 5, fdata
SetFormula fdata "Gauss2D(coeffs, x, y)"
Variable /G x_offset = 2
Display; AppendImage /L/B fdata
ControlBar 35
SetVariable x_offset_ctl, value=x_offset, fsize=12, pos={35, 10}, size={120, 15}
Then ideally I'd say:
SetFormula coeffs "{0, 4, x_offset, 1, 1, 4, 0}"
I know it's possible to do this writing a procedure for the control, but with many parameters it becomes a little unwieldy.
Wondering if there's an internal way I'm missing to explicitly set dependencies for wave components?
Thanks!
Dave
It is best to avoid dependencies altogether. They create hidden interactions which makes them difficult to understand and they are difficult to debug. Instead just have your action procedure for the SetVariable control do whatever needs to be done.
April 27, 2014 at 02:03 pm - Permalink