commit b920c8484f39977f9bed9edc45ca2039bdfda197
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon May 13 23:00:33 2019 +0100

    1. Change the API of Dynamic: split makeNowRunFor into two separate 'setDuration' and 'resetToBeginning'
    2. Major changes to the 'Dynamic' app so that we can check more about the Dynamics.

diff --git a/src/main/java/org/distorted/library/type/Dynamic.java b/src/main/java/org/distorted/library/type/Dynamic.java
index 72aeb3d..0caf5d1 100644
--- a/src/main/java/org/distorted/library/type/Dynamic.java
+++ b/src/main/java/org/distorted/library/type/Dynamic.java
@@ -154,8 +154,8 @@ public abstract class Dynamic
   private static Random mRnd = new Random();
   private static final int NUM_NOISE = 5; // used iff mNoise>0.0. Number of intermediary points between each pair of adjacent vectors
                                           // where we randomize noise factors to make the way between the two vectors not so smooth.
-  private long mTimeLastInterpolated;
-  private long mTimeWhenSetDuration;
+  private long mTimeOffset;
+  private boolean mSetOffset;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // hide this from Javadoc
@@ -181,8 +181,8 @@ public abstract class Dynamic
     mLastPos   = -1;
     mAccessMode= ACCESS_RANDOM;
 
-    mTimeLastInterpolated = 0;
-    mTimeWhenSetDuration  = 0;
+    mTimeOffset = 0;
+    mSetOffset  = true;
 
     baseV      = new float[mDimension][mDimension];
     buf        = new float[mDimension];
@@ -544,15 +544,40 @@ public abstract class Dynamic
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Sets the time it takes to do one full interpolation.
- * 
- * @param durationInMilliseconds time it takes to do one full interpolation, i.e. go from the first
- *                               Point to the last and back.
+ * Return the number of times this Dynamic will interpolate.
+ *
+ * @return the number of times this Dynamic will interpolate.
+ */
+  public float getCount()
+    {
+    return mCount;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Start running from the beginning again.
  */
-  public void makeRunNowFor(long durationInMilliseconds)
+  public void resetToBeginning()
     {
-    mDuration = durationInMilliseconds;
-    mTimeWhenSetDuration = mTimeLastInterpolated;
+    mSetOffset = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @param duration Number of milliseconds this Dynamic will interpolate for.
+ */
+  public void setDuration(long duration)
+    {
+    mDuration = duration;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @return Number of milliseconds this Dynamic will interpolate for.
+ */
+  public long getDuration()
+    {
+    return mDuration;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -587,15 +612,22 @@ public abstract class Dynamic
  */
   public void get(float[] buffer, int offset, long time)
     {
-    mTimeLastInterpolated = time;
-
     if( mDuration<=0.0f )
       {
       interpolate(buffer,offset,mCount-(int)mCount);
       }
     else
       {
-      double pos = (double)(time-mTimeWhenSetDuration)/mDuration;
+      if( mSetOffset )
+        {
+        mSetOffset = false;
+        mTimeOffset= time;
+        mLastPos   = -1;
+        }
+
+      time -= mTimeOffset;
+
+      double pos = (double)time/mDuration;
 
       if( pos<=mCount || mCount<=0.0f )
         {
@@ -622,14 +654,21 @@ public abstract class Dynamic
  */
   public boolean get(float[] buffer, int offset, long time, long step)
     {
-    mTimeLastInterpolated = time;
-    time -= mTimeWhenSetDuration;
-
     if( mDuration<=0.0f )
       {
       interpolate(buffer,offset,mCount-(int)mCount);
       return false;
       }
+
+    if( mSetOffset )
+      {
+      mSetOffset = false;
+      mTimeOffset= time;
+      mLastPos   = -1;
+      }
+
+    time -= mTimeOffset;
+
     if( time+step > mDuration*mCount && mCount>0.0f )
       {
       interpolate(buffer,offset,mCount-(int)mCount);
