function reapPoincarePoints(energy, npt, initB, initLB, deltaT, maxSteps) {
    var poincPoints = new Array();
    var foundPoints = 0, iter = 0;
    var curPoint = initConds(energy, initB, initLB), newPoint;
    var tCross, newB, newLB;

    // We will return the initial point as element 0
    poincPoints.push([initB, initLB]);

    // Fence-post issue with JXG.Math.Numerics.rungeKutta .
    // To get it to take one step, we need to tell it we want a total
    // of two steps on the interval, because it counts the 0th step.
    deltaT = 2.*deltaT;

    do {
      // Take an RK step
      newPoint = JXG.Math.Numerics.rungeKutta(
        'rk4',        // Butcher table
        curPoint,     // Initial conditions
        [0., deltaT], // time interval
        2,            // how many points
        ODERHS        // the RHS of the system
      );

      // Just get the new point
      newPoint = newPoint[1];

      // Check if there has been a zero-crossing for a, in the
      // positive direction
      if ((curPoint[0] < 0) && (newPoint[0] >= 0) ) {
        // We found a new point on the section!
        foundPoints++;

        // Find the approximate time of crossing
        tCross = zeroCrossing(0., curPoint[0], deltaT, newPoint[0]);

        // Interpolate the values of b, lb
        newB  = linearInterp(tCross, 0., curPoint[2], deltaT, newPoint[2]);
        newLB = linearInterp(tCross, 0., curPoint[3], deltaT, newPoint[3]);

        // store it
        poincPoints.push([newB, newLB]);
      };

      // Next
      iter++;
      curPoint = newPoint;

    } while ( (iter <= maxSteps) && (foundPoints < npt) );

    return poincPoints;
  }
/* This is the heart of the toy.
   * Tries to yield npt _new_ points in the (b,lb) plane.
   * Returns an Array, hopefully of length npt+1, where the 0th
   * element is the initial point that was passed, and the rest are new.
   * Stops if maxSteps is reached, so it may yield fewer points.
   */
This is the heart of the toy.
Tries to yield npt _new_ points in the (b,lb) plane.
Returns an Array, hopefully of length npt+1, where the 0th
element is the initial point that was passed, and the rest are new.
Stops if maxSteps is reached, so it may yield fewer points.
This is the heart of the toy . Tries to yield npt _new_ points in the ( b lb ) plane . Returns an Array hopefully of length npt + 1 where the 0th element is the initial point that was passed and the rest are new . Stops if maxSteps is reached so it may yield fewer points .
function reapPoincarePoints(energy, npt, initB, initLB, deltaT, maxSteps) {
    var poincPoints = new Array();
    var foundPoints = 0, iter = 0;
    var curPoint = initConds(energy, initB, initLB), newPoint;
    var tCross, newB, newLB;
    poincPoints.push([initB, initLB]);
    deltaT = 2.*deltaT;
    do {
      newPoint = JXG.Math.Numerics.rungeKutta(
        'rk4',        
        curPoint,     
        [0., deltaT], 
        2,            
        ODERHS        
      );
      newPoint = newPoint[1];
      if ((curPoint[0] < 0) && (newPoint[0] >= 0) ) {
        foundPoints++;
        tCross = zeroCrossing(0., curPoint[0], deltaT, newPoint[0]);
        newB  = linearInterp(tCross, 0., curPoint[2], deltaT, newPoint[2]);
        newLB = linearInterp(tCross, 0., curPoint[3], deltaT, newPoint[3]);
        poincPoints.push([newB, newLB]);
      };
      iter++;
      curPoint = newPoint;
    } while ( (iter <= maxSteps) && (foundPoints < npt) );
    return poincPoints;
  }
function reapPoincarePoints ( energy , npt , initB , initLB , deltaT , maxSteps ) { var poincPoints = new Array ( ) ; var foundPoints = 0 , iter = 0 ; var curPoint = initConds ( energy , initB , initLB ) , newPoint ; var tCross , newB , newLB ; poincPoints . push ( [ initB , initLB ] ) ; deltaT = 2. * deltaT ; do { newPoint = JXG . Math . Numerics . rungeKutta ( 'rk4' , curPoint , [ 0. , deltaT ] , 2 , ODERHS ) ; newPoint = newPoint [ 1 ] ; if ( ( curPoint [ 0 ] < 0 ) && ( newPoint [ 0 ] >= 0 ) ) { foundPoints ++ ; tCross = zeroCrossing ( 0. , curPoint [ 0 ] , deltaT , newPoint [ 0 ] ) ; newB = linearInterp ( tCross , 0. , curPoint [ 2 ] , deltaT , newPoint [ 2 ] ) ; newLB = linearInterp ( tCross , 0. , curPoint [ 3 ] , deltaT , newPoint [ 3 ] ) ; poincPoints . push ( [ newB , newLB ] ) ; } ; iter ++ ; curPoint = newPoint ; } while ( ( iter <= maxSteps ) && ( foundPoints < npt ) ) ; return poincPoints ; }
This is the heart of the toy.
This is the heart of the toy .
// We will return the initial point as element 0 // Fence-post issue with JXG.Math.Numerics.rungeKutta . // To get it to take one step, we need to tell it we want a total // of two steps on the interval, because it counts the 0th step. // Take an RK step // Butcher table // Initial conditions // time interval // how many points // the RHS of the system // Just get the new point // Check if there has been a zero-crossing for a, in the // positive direction // We found a new point on the section! // Find the approximate time of crossing // Interpolate the values of b, lb // store it // Next