Merged in mmastriani/fractorium_michel (pull request #20)

Added poincare2

Approved-by: Matt Feemster <matt.feemster@gmail.com>
This commit is contained in:
Michel Mastriani 2019-05-24 17:41:36 +00:00 committed by Matt Feemster
commit 9da35982f0
4 changed files with 100 additions and 11 deletions

View File

@ -312,6 +312,7 @@ enum class eVariationId : et
VAR_PIE3D ,
VAR_PIXEL_FLOW ,
VAR_POINCARE ,
VAR_POINCARE2 ,
VAR_POINCARE3D ,
VAR_POINT_SYMMETRY,
VAR_POLAR ,
@ -725,6 +726,7 @@ enum class eVariationId : et
VAR_PRE_PIE3D,
VAR_PRE_PIXEL_FLOW,
VAR_PRE_POINCARE,
VAR_PRE_POINCARE2,
VAR_PRE_POINCARE3D,
VAR_PRE_POINT_SYMMETRY,
VAR_PRE_POLAR,
@ -1137,6 +1139,7 @@ enum class eVariationId : et
VAR_POST_PIE3D,
VAR_POST_PIXEL_FLOW,
VAR_POST_POINCARE,
VAR_POST_POINCARE2,
VAR_POST_POINCARE3D,
VAR_POST_POINT_SYMMETRY,
VAR_POST_POLAR,

View File

@ -172,6 +172,7 @@ VariationList<T>::VariationList()
ADDPREPOSTREGVAR(NPolar)
ADDPREPOSTREGVAR(Ortho)
ADDPREPOSTREGVAR(Poincare)
ADDPREPOSTREGVAR(Poincare2)
ADDPREPOSTREGVAR(Poincare3D)
ADDPREPOSTREGVAR(Polynomial)
ADDPREPOSTREGVAR(PSphere)

View File

@ -4493,6 +4493,93 @@ private:
T m_C2d;
};
/// <summary>
/// Poincare2.
/// </summary>
template <typename T>
class Poincare2Variation : public ParametricVariation<T>
{
public:
Poincare2Variation(T weight = 1.0) : ParametricVariation<T>("poincare2", eVariationId::VAR_POINCARE2, weight)
{
Init();
}
PARVARCOPY(Poincare2Variation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T a = helper.In.x - m_Cx;
T b = helper.In.y - m_Cy;
T c = T(1) - m_Cx * helper.In.x - m_Cy * helper.In.y;
T d = m_Cy * helper.In.x - m_Cx * helper.In.y;
T num = m_Weight / (c * c + d * d);
helper.Out.x = (a * c + b * d) * num;
helper.Out.y = (b * c - a * d) * num;
helper.Out.z = DefaultZ(helper);
}
virtual string OpenCLString() const override
{
ostringstream ss, ss2;
intmax_t i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string weight = WeightDefineString();
string cP = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string cQ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string cX = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string cY = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t a = vIn.x - " << cX << ";\n"
<< "\t\treal_t b = vIn.y - " << cY << ";\n"
<< "\t\treal_t c = 1 - " << cX << " * vIn.x - " << cY << " * vIn.y;\n"
<< "\t\treal_t d = " << cY <<" * vIn.x - " << cX << " * vIn.y;\n"
<< "\t\treal_t num = " << weight <<" / (c * c + d * d);\n"
<< "\n"
<< "\t\tvOut.x = (a * c + b * d) * num;\n"
<< "\t\tvOut.y = (b * c - a * d) * num;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
}
virtual void Precalc() override
{
T a0 = M_2PI / m_PoincareP;
T dist2 = T(1) - (cos(a0) - T(1)) / (cos(a0) + cos(M_2PI / m_PoincareQ));
T dist = (dist2 > T(0)) ? T(1) / sqrt(dist2) : T(1);
if (T(1) / m_PoincareP + T(1) / m_PoincareQ < T(0.5))
{
m_Cx = cos(a0) * dist;
m_Cy = sin(a0) * dist;
}
else
m_Cx = m_Cy = T(0);
}
protected:
void Init()
{
string prefix = Prefix();
m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_PoincareP, prefix + "poincare_p", 3));
m_Params.push_back(ParamWithName<T>(&m_PoincareQ, prefix + "poincare_q", 7));
m_Params.push_back(ParamWithName<T>(true, &m_Cx, prefix + "poincare_cx")); //Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Cy, prefix + "poincare_cy"));
}
private:
T m_PoincareP;
T m_PoincareQ;
T m_Cx; //Precalc.
T m_Cy;
};
/// <summary>
/// Poincare3D.
/// </summary>
@ -6014,6 +6101,7 @@ MAKEPREPOSTPARVAR(Murl2, murl2, MURL2)
MAKEPREPOSTPARVAR(NPolar, npolar, NPOLAR)
MAKEPREPOSTPARVAR(Ortho, ortho, ORTHO)
MAKEPREPOSTPARVAR(Poincare, poincare, POINCARE)
MAKEPREPOSTPARVAR(Poincare2, poincare2, POINCARE2)
MAKEPREPOSTPARVAR(Poincare3D, poincare3D, POINCARE3D)
MAKEPREPOSTPARVAR(Polynomial, polynomial, POLYNOMIAL)
MAKEPREPOSTPARVAR(PSphere, psphere, PSPHERE)

View File

@ -908,13 +908,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (!varname.empty())
{
T weight = 1;
string corrvarname;
if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't.
corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname);
else
corrvarname = varname;
string corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname);
auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname;
if (auto var = m_VariationList->GetVariation(corrwprefix))
@ -2486,11 +2480,14 @@ string XmlToEmber<T>::GetCorrectedVariationName(vector<pair<pair<string, string>
template <typename T>
string XmlToEmber<T>::GetCorrectedVariationName(vector<pair<pair<string, string>, vector<string>>>& vec, const string& varname)
{
for (auto& v : vec)
if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here.
return v.first.second;
if (varname == "poincare")//for Apo flames, poincare must be the same, but chaotica poincare is implemented as poincare2
return "poincare2";
else if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't.
for (auto& v : vec)
if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here.
return v.first.second;
return varname;
return varname;
}
/// <summary>