Chaotic Motion  1.0
ChaoticSystem.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
22 public class ChaoticSystem : MonoBehaviour {
28 
29  public const string NO_PARAM = "none";
30 
32  public float timeZoom = 1f;
33 
35  public int selectedEqn;
37  public int selectedParams;
38 
40  public Vector3 evolveScale = Vector3.one;
41 
43  public ParamBundle customParams = null;
44 
46  public bool paramFoldout = false;
47  public bool speedFoldout = false;
48 
49  public virtual void Init() {
50  Debug.LogError("Must override this method");
51  }
52 
53  // Time evolution
54  // time evolution
55  protected float physicsTime;
56  protected float worldTime;
57  // minimum DT is driven by evolution of Lorenz on outer loops (where it moves fast)
58  protected float DT = 0.005f;
59 
60  protected void TimeInit() {
61  worldTime = Time.time;
62  physicsTime = worldTime*timeZoom;
63  }
64 
65  protected int CalcNumSteps() {
66 
67  worldTime += Time.fixedDeltaTime;
68  float timeSlice = Mathf.Max(worldTime - physicsTime/timeZoom, 0);
69  int numSteps = Mathf.RoundToInt(timeSlice/DT);
70  physicsTime += numSteps * DT;
71  return numSteps;
72  }
73 
74 }
ParamBundle customParams
Custom parameter values for evolution (valid only if selectedParams exceeds number of params listed i...
Chaotic system. Base class for chaotic scripts. Holds the type of system selected, the parameter set or the custom parameters to be used.
int selectedEqn
Number of chaos system to evolve (w.r.t. ChaosFactory list)
float timeZoom
Time scale (>0)
Vector3 evolveScale
Scale to apply to phyics evolution when mapping back to world space.
bool paramFoldout
Editor foldout tab status.
Parameter bundle. Container class to hold the values for starting a chaotic system. Holds the parameters for the equations and the initial position and scale values.
Definition: ParamBundle.cs:13
int selectedParams
Number of parameter bundle selected for evolution (per chaotic equation)