summaryrefslogtreecommitdiff
path: root/gui/libs/ofxAChaosLib/src/AChaosDuffing.h
blob: 338c324865d034aa349cfab1df3a7781edf7fa3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
	32/64 bits A-Chaos Lib in openFrameworks	
	(c) s373.net/x 2004, 2012, 2015
	http://s373.net/code/A-Chaos-Lib/A-Chaos.html
	programmed by Andre Sier, revised 2015
	License: MIT
*/
#pragma once
#include "AChaosBase.h"

class AChaosDuffing : public AChaosBase {
public:

	REAL a, b, w, t, dt, nx, ny;
	
	AChaosDuffing(){}
	~AChaosDuffing(){}	

	vector<string> param_labels={"a","b","w","t","dt","",""};

	virtual void setup(REAL * params = NULL){
	
		AChaosBase::init(params, 7, 2);	
		if(params==NULL){	
			//init	
			a = 0.25f;
			b = 0.3f;
			w = 1.0f;
			nx = 0.0f;
			ny = 0.0f;
			dt = 0.01f;
			t = 0.0f;
			REAL p[7] = {a,b,w,nx,ny,dt,t};
			set(p);
		}  else { set(params); }
	
	}

	void reset(){
		a = iv[0];
		b = iv[1];
		w = iv[2];
		nx = iv[3];
		ny = iv[4];
		dt = iv[5];
		t = iv[6];
	}
	
 	void calc(){ 		
		t += dt;
		nx = ny;
		ny = nx-(nx*nx*nx)-(a*ny)+(b*COS(w*t));

		ov[0] = nx;
		ov[1] = ny;
 	}
};