//Butterfly curve. //Bourke, P. "Butterfly Curve." http://astronomy.swin.edu.au/~pbourke/curves/butterfly/. #include Double_t x_fun(Double_t t) { using namespace TMath; return Sin(t) * (Exp(Cos(t)) - 2 * Cos(4 * t) + Power(Sin(1 / 12. * t), 5)); //return 1.3 * TMath::Cos(t);//ellipse } Double_t y_fun(Double_t t) { using namespace TMath; return Cos(t) * (Exp(Cos(t)) - 2 * Cos(4 * t) + Power(Sin(1 / 12. * t), 5)); //return TMath::Sin(t);//ellipse } void param() { const Double_t tMin = 0., tMax = 15 * TMath::TwoPi(); const Int_t nPoints = 2000; const Double_t step = (tMax - tMin) / (nPoints - 1); std::vector xArr(nPoints), yArr(nPoints); for(Int_t i = 0; i < nPoints; ++i) { xArr[i] = x_fun(tMin + i * step); yArr[i] = y_fun(tMin + i * step); } TGraph *graph = new TGraph(nPoints, &xArr[0], &yArr[0]); graph->SetLineColor(kRed); TCanvas *c = new TCanvas("parametric", "parametric", 100, 100, 400, 400); c->Range(-4.5, -4.5, 4.5, 4.5); graph->Draw(); }