Class myphysicslab.lab.util.GenericMemo

Provided By
All Implemented Interfaces

A generic Memorizable object that calls a JavaScript function.

Example 1

Make a GenericMemo that prints the angle variable of a simulation into the myphysicslab.lab.util.Terminal output area. Here simRun is an instance of

var angle = sim.getVarsList().getVariable('ANGLE');
var memo = new GenericMemo(function(){println('angle: '+angle.getValue())});

This code can be entered as Terminal commands in myphysicslab.sims.pendulum.PendulumApp if using simple-compiled version.

Example 2

This sets the color of a spring depending on how much it is stretched.

var spring = simList.get('spring1');
var dispSpring = displayList.find(spring);
var memo = new GenericMemo(function() {
  var stretch = Math.max(Math.min(spring.getStretch(), 1), -1);
  if (stretch < 0) {
    dispSpring.setColorCompressed(UtilityCore.colorString3(-stretch, 0, 0));
  } else {
    dispSpring.setColorExpanded(UtilityCore.colorString3(0, stretch, 0));

This script can be entered as Terminal commands in myphysicslab.sims.engine2D.CartPendulum2App if using simple-compiled version.

new GenericMemo( func, opt_purpose )

funcfunction(): ?

function to execute


Describes what this GenericMemo does, for debugging

Instance Methods