2 using System.Collections;
28 private Vector3 initialPosition;
29 private Vector3 lastTrail;
43 private bool diverged;
53 public override void Init() {
62 initialPosition = transform.position;
63 lastTrail = transform.position;
68 chaosTrail = GetComponentInChildren<ChaosTrail>();
74 private void StartAt(Vector3 xstart) {
81 private Vector3 Evolve(
float h) {
83 Vector3 xout = Vector3.zero;
86 arg[0] = x[0] + h_frac * a_n[0];
87 arg[1] = x[1] + h_frac * a_n[1];
88 arg[2] = x[2] + h_frac * a_n[2];
90 arg[0] = x[0] + h_frac * b_n[0];
91 arg[1] = x[1] + h_frac * b_n[1];
92 arg[2] = x[2] + h_frac * b_n[2];
95 arg[0] = x[0] + h_frac * c_n[0];
96 arg[1] = x[1] + h_frac * c_n[1];
97 arg[2] = x[2] + h_frac * c_n[2];
100 xout.x = x[0] + h_frac*(a_n[0] + 2f * b_n[0] + 2f * c_n[0] + d_n[0]);
101 xout.y = x[1] + h_frac*(a_n[1] + 2f * b_n[1] + 2f * c_n[1] + d_n[1]);
102 xout.z = x[2] + h_frac*(a_n[2] + 2f * b_n[2] + 2f * c_n[2] + d_n[2]);
111 if (diverged || paused) {
115 Vector3 position = transform.position;
117 int numSteps = CalcNumSteps();
119 for (
int i=0; i < numSteps; i++) {
124 if (
float.IsNaN(phyPos.x) ||
float.IsNaN(phyPos.y) ||
float.IsNaN(phyPos.z)) {
125 Debug.LogWarning(
"Position diverged");
131 position = Vector3.Scale(phyPos,
evolveScale) + initialPosition;
132 position = transform.rotation * position;
133 if (chaosTrail != null) {
136 lastTrail = position;
140 transform.position = position;
ParamBundle paramBundle
The parameter bundle that is used to evolve the system.
void AddPoint(Vector3 point)
Adds a point to the trail.
ParamBundle customParams
Custom parameter values for evolution (valid only if selectedParams exceeds number of params listed i...
static ChaosEqn Create(int index, int paramIndex, ParamBundle customParams)
Create the ChaosEqn implementation for the specified index in the eqnList, with the selected param bu...
Chaotic system. Base class for chaotic scripts. Holds the type of system selected, the parameter set or the custom parameters to be used.
float scale
scale to ensure that attractor fits in box of size 10
float minVertexDistance
Distance interval for points to be added to the renderer.
int selectedEqn
Number of chaos system to evolve (w.r.t. ChaosFactory list)
Chaos trail. Update a trail using a LineRenderer. This allows the path between points to be filled in...
abstract void Function(ref float[] x_in, ref float[] x_dot)
Evaluate the first order evolution of the attractor, given the current position.
Vector3 evolveScale
Scale to apply to phyics evolution when mapping back to world space.
Vector3 initialPosition
Initial position for evolution in physics space.
Chaos eqn. Base class for all equations that define a 3D chaotic system.
Vector3 offset
offset to center attractor at local origin
Chaotic motion. Evolve the user specified chaotic system with the parameters held by the ChaoticSyste...
override void Init()
Init the equation using the selected equation and parameter bundle.
int selectedParams
Number of parameter bundle selected for evolution (per chaotic equation)