APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

clearTraces post and replies

Return to the clearTraces thread
Login to post to this thread

clearTraces
Cleon Teunissen
29 Posts

EJS has pre-written actions, the most frequently used are _play(), _pause(), _step(), and _reset().

In many of my EJS simulations I add a button 'Clear Traces', which on clicking invokes the action _view.resetTraces()

As far as I can tell, there is no 'resetTraces' in EJsS.

I have created a combination of two screenshots. See the attached image, EJsS_EJS_actions.png

The left column is all of the pre-written actions that are available in the EJsS environment, the column on the right is the list of pre-written actions available in the EJS environment.

Is the absence of a pre-written clearTraces() action intentional, or is it a regression that at some point in the future will be corrected?

Cleon Teunissen

Attached File: EJsS_EJS_actions.png


Replies to clearTraces

Re: clearTraces -
Cleon Teunissen
29 Posts

Let me give this request for information one more try.

I have in the meantime verified the that Lagrange point simulation does run. The Javascript version produces the same orbital motion as the Java version does, so that's in the bag.

However, for this type of simulation ability to clear traces is a necessity. The fun of it is that you try a simulation run, then you clear the traces, and you do some tweaking of the initial conditions and see how that makes a difference.

At present the only way to clear the traces is to reload the entire webpage.

As a shot to nothing I tried whether the 'Maximum' attribute of the 'trace' element offers a possibility. To that end I created a variable 'secTraceMaxPoints' for the 'Maximum' field, and this custom method:

function clearTraces() {
  secTraceMaxPoints = 0;
  secTraceMaxPoints = 1023;
}

Well, invoking that function had no effect, the trace wasn't cleared.


Is there anything else I can try to achieve the goal of having the ability to clear the traces?



Re: clearTraces -
Wolfgang
192 Posts

Use the following functions to clear data from a trace and to set the maximum number of points.

_view.TRACE_NAME.clear();
_view.TRACE_NAME.setMaximumPoints(NUMBER);

You can append new points to a trace using

_view.TRACE_NAME.addPoints(X_ARRAY, Y_ARRAY);

The view should update automatically if these functions are called from a user action or from the Evolution page.  If not, you may need to update the view for the changes to take effect.

_view._update();

You can see how these functions are used in the accelerometer example:

https://www.compadre.org/OSP/items/Detail.cfm?ID=15159



Re: clearTraces -
Cleon Teunissen
29 Posts

Thank you so much.

In all there are three traces in the simulation, for simplicity I will refer to them as 'trace1', 'trace2', 'trace3'

I verified that following function acts as overall clearTraces function:

function clearTraces() {
  _view.trace1.clear();
  _view.trace2.clear();
  _view.trace3.clear();
}

There was no need to call _view._update();



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book