Commit 59a21ae5 authored by BrutPitt's avatar BrutPitt
Browse files

ver 1.6.0 WiP - reorganize attractorsBase (h/cpp) files : move 2D attractors...

ver 1.6.0 WiP - reorganize attractorsBase (h/cpp) files : move 2D attractors transformed in 3D/4D attractors, in separate files
parent 03b23c42
//------------------------------------------------------------------------------
// Copyright (c) 2018-2020 Michele Morrone
// All rights reserved.
//
// https://michelemorrone.eu - https://BrutPitt.com
//
// twitter: https://twitter.com/BrutPitt - github: https://github.com/BrutPitt
//
// mailto:brutpitt@gmail.com - mailto:me@michelemorrone.eu
//
// This software is distributed under the terms of the BSD 2-Clause license
//------------------------------------------------------------------------------
#include "glWindow.h"
////////////////////////////////////////////////////////////////////////////
void Mira3D::Step(vec4 &v, vec4 &vp)
{
auto f = [] (float x, float k) -> float {
const float x2 = x*x;
return k*x + 2.f*(1.f-k)*x2 / (1+x2);
};
vp.x = v.y + f(v.x, kVal[0]);
const float vpp = f(vp.x, kVal[0]);
vp.y = vpp - v.x;
vp.z = f(v.z, kVal[3]) + f(vp.y, kVal[2]) + f(vpp, kVal[1]);
}
////////////////////////////////////////////////////////////////////////////
void Mira4D::Step(vec4 &v, vec4 &vp)
{
auto f = [] (const float x, const float k) -> float {
const float x2 = x*x;
return k*x + 2.f*(1.f-k)*x2 / (1+x2);
};
vp.x = kVal[1]*v.y + f(v.x, kVal[0]);
vp.y = - v.x + f(vp.x, kVal[0]);
vp.z = kVal[3]*v.w + f(v.z, kVal[2]);
vp.w = - v.z + f(vp.z, kVal[2]);
}
////////////////////////////////////////////////////////////////////////////
void PopCorn3D::Step(vec4 &v, vec4 &vp)
{
vp.x = v.x - kVal[0] * sin((double)v.z+tan((double)kVal[1]*v.z));
vp.y = v.y - kVal[2] * sin((double)v.x+tan((double)kVal[3]*v.x));
vp.z = v.z - kVal[4] * sin((double)v.y+tan((double)kVal[5]*v.y));
}
////////////////////////////////////////////////////////////////////////////
void PopCorn4Dset::Step(vec4 &v, vec4 &vp)
{
vp.x = v.x - kVal[0] * pfX((double)v.y+tan((double)kVal[1]*v.y));
vp.y = v.y - kVal[2] * pfY((double)v.x+tan((double)kVal[3]*v.x));
vp.z = v.z - kVal[4] * pfZ((double)v.w+tan((double)kVal[5]*v.w));
vp.w = v.w - kVal[6] * pfW((double)v.z+tan((double)kVal[7]*v.z));
}
////////////////////////////////////////////////////////////////////////////
void PopCorn4Dsimple::Step(vec4 &v, vec4 &vp)
{
vp.x = kVal[0] * pfX((double)v.y+tan((double)kVal[1]*v.y));
vp.y = kVal[2] * pfY((double)v.x+tan((double)kVal[3]*v.x));
vp.z = kVal[4] * pfZ((double)v.w+tan((double)kVal[5]*v.w));
vp.w = kVal[6] * pfW((double)v.z+tan((double)kVal[7]*v.z));
}
////////////////////////////////////////////////////////////////////////////
void PopCorn4Drnd::Step(vec4 &v, vec4 &vp)
{
vp.x = kVal[0] - kVal[1]*v.x*v.x + v.y;
vp.y = kVal[2]*v.x;
vp.z = kVal[3] - kVal[4]*v.z*v.z + v.w;
vp.w = kVal[5]*v.z;
}
////////////////////////////////////////////////////////////////////////////
void Martin4DBase::Step(vec4 &v, vec4 &vp)
{
vp.x = v.y - pfX((double)v.x);
vp.y = kVal[0] - v.x;
vp.z = v.w - pfZ((double)v.z);
vp.w = kVal[1] - v.z;
}
////////////////////////////////////////////////////////////////////////////
void SymmetricIcons4D::Step(vec4 &v, vec4 &vp)
{
//alpha, beta, gamma, lambda, omega, degree
const float sqrXY = v.x*v.x + v.y*v.y;
const float sqrZW = v.z*v.z + v.w*v.w;
float pXY = kVal[0]*sqrXY + kVal[3];
float pZW = kVal[5]*sqrZW + kVal[8];
vec4 newP(v);
for(int i=6; i>0; i--) {
newP = vec4(newP.x*v.x - newP.y*v.y, newP.y*v.x + newP.x*v.y,
newP.z*v.z - newP.w*v.w, newP.w*v.z + newP.z*v.w);
}
float nXY = v.x*newP.x - v.y*newP.y;
float nZW = v.z*newP.z - v.w*newP.w;
pXY = pXY + kVal[1]*nXY;
pZW = pZW + kVal[6]*nZW;
vp = vec4(pXY*v.x + kVal[2]*newP.x - kVal[4]*v.y,
pXY*v.y + kVal[2]*newP.y - kVal[4]*v.x,
pZW*v.z + kVal[7]*newP.z - kVal[9]*v.w,
pZW*v.w + kVal[7]*newP.w - kVal[9]*v.z );
}
////////////////////////////////////////////////////////////////////////////
void Hopalong4D::Step(vec4 &v, vec4 &vp)
{
auto func = [](const float f, const float k1, const float k2) {
return (f>0 ? 1 : -1) * sqrt(abs(k1*f-k2));
};
vp.x = v.y - func(v.x, kVal[1], kVal[2]);
vp.y = kVal[0] - v.x;
vp.z = v.w - func(v.z, kVal[4], kVal[5]);
vp.w = kVal[3] - v.z;
}
//------------------------------------------------------------------------------
// Copyright (c) 2018-2020 Michele Morrone
// All rights reserved.
//
// https://michelemorrone.eu - https://BrutPitt.com
//
// twitter: https://twitter.com/BrutPitt - github: https://github.com/BrutPitt
//
// mailto:brutpitt@gmail.com - mailto:me@michelemorrone.eu
//
// This software is distributed under the terms of the BSD 2-Clause license
//------------------------------------------------------------------------------
#pragma once
// Mira3D
////////////////////////////////////////////////////////////////////////////
class Mira3D : public attractorScalarK
{
public:
Mira3D() {
stepFn = (stepPtrFn) &Mira3D::Step;
vMin = -10.0; vMax = 10.0; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 12.f);
}
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
void searchAttractor() { searchLyapunov(); }
};
// Mira4D
////////////////////////////////////////////////////////////////////////////
class Mira4D : public attractorScalarK
{
public:
Mira4D() {
stepFn = (stepPtrFn) &Mira4D::Step;
vMin = -10.0; vMax = 10.0; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 50.f);
}
int getPtSize() { return attPt4D; }
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
void searchAttractor() { searchLyapunov(); }
};
// PopCorn 4D BaseClasses
////////////////////////////////////////////////////////////////////////////
class PopCorn4DType : public attractorScalarK
{
public:
PopCorn4DType() {
vMin = -1.0; vMax = 1.0; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 12.f);
}
int getPtSize() { return attPt4D; }
protected:
virtual void startData();
//virtual void additionalDataCtrls();
};
class PopCorn4Dset : public PopCorn4DType
{
public:
void Step(vec4 &v, vec4 &vp);
protected:
double (*pfX)(double), (*pfY)(double), (*pfZ)(double), (*pfW)(double);
};
// PopCorn 4D
////////////////////////////////////////////////////////////////////////////
class PopCorn4D : public PopCorn4Dset
{
public:
PopCorn4D() { stepFn = (stepPtrFn) &PopCorn4Dset::Step;
pfX = pfY = pfZ = pfW = sin; }
};
////////////////////////////////////////////////////////////////////////////
class PopCorn4Dscss : public PopCorn4Dset
{
public:
PopCorn4Dscss() { stepFn = (stepPtrFn) &PopCorn4Dset::Step;
pfX = pfZ = pfW = sin; pfY = cos; }
};
////////////////////////////////////////////////////////////////////////////
class PopCorn4Dscsc : public PopCorn4Dset
{
public:
PopCorn4Dscsc() { stepFn = (stepPtrFn) &PopCorn4Dset::Step;
pfX = pfZ = sin; pfY = pfW = cos; }
};
////////////////////////////////////////////////////////////////////////////
class PopCorn4Dsscc : public PopCorn4Dset
{
public:
PopCorn4Dsscc() { stepFn = (stepPtrFn) &PopCorn4Dset::Step;
pfX = pfY = sin; pfZ = pfW = cos; }
};
class PopCorn4Dsimple : public PopCorn4DType
{
public:
PopCorn4Dsimple() { stepFn = (stepPtrFn) &PopCorn4Dsimple::Step;
pfX = pfY = pfZ = pfW = sin; }
void Step(vec4 &v, vec4 &vp);
protected:
double (*pfX)(double), (*pfY)(double), (*pfZ)(double), (*pfW)(double);
};
////////////////////////////////////////////////////////////////////////////
class PopCorn4Drnd : public PopCorn4DType
{
public:
void startData();
PopCorn4Drnd() { stepFn = (stepPtrFn) &PopCorn4DType::Step; }
protected:
void Step(vec4 &v, vec4 &vp);
};
// PopCorn 3D
////////////////////////////////////////////////////////////////////////////
class PopCorn3D : public attractorScalarK
{
public:
PopCorn3D() {
stepFn = (stepPtrFn) &PopCorn3D::Step;
vMin = -1.0; vMax = 1.0; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 12.f);
}
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
};
// Martin 4D
////////////////////////////////////////////////////////////////////////////
class Martin4DBase : public attractorScalarK
{
public:
Martin4DBase() {
vMin = .0; vMax = .5; kMin = 2.7; kMax = 3.0;
m_POV = vec3( 0.f, 0, 50.f);
}
int getPtSize() { return attPt4D; }
void Step(vec4 &v, vec4 &vp);
protected:
double (*pfX)(double), (*pfZ)(double);
void startData();
};
class Martin4D : public Martin4DBase
{
public:
Martin4D() { stepFn = (stepPtrFn) &Martin4DBase::Step; pfX = pfZ = sin; }
};
class Martin4Dsc : public Martin4DBase
{
public:
Martin4Dsc() { stepFn = (stepPtrFn) &Martin4DBase::Step; pfX = sin; pfZ = cos; }
};
class Martin4Dcc : public Martin4DBase
{
public:
Martin4Dcc() { stepFn = (stepPtrFn) &Martin4DBase::Step; pfX = pfZ = cos; }
};
// Symmetric Icons
////////////////////////////////////////////////////////////////////////////
class SymmetricIcons4D : public attractorScalarK
{
public:
SymmetricIcons4D() {
stepFn = (stepPtrFn) &SymmetricIcons4D::Step;
vMin = -1.0; vMax = 1.0; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 12.f);
}
int getPtSize() { return attPt4D; }
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
};
// Hopalong 4D
////////////////////////////////////////////////////////////////////////////
class Hopalong4D : public attractorScalarK
{
public:
Hopalong4D() {
stepFn = (stepPtrFn) &Hopalong4D::Step;
vMin = -1.0; vMax = 1.0; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 50.f);
}
int getPtSize() { return attPt4D; }
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
//void searchAttractor() { searchLyapunov(); }
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment