===== oblate_prolate ===== // Show rendering of parametric surfaces. // Author: Timur Pocheptsov void oblate_prolate() { // A parametric surface is defined by three functions: // S(u, v) : {x(u, v), y(u, v), z(u, v)}. // To create parametric surface and draw it one has to: // 1. Create canvas, which support OpenGL drawing (two ways): // a. Call gStyle->SetCanvasPreferGL(kTRUE) // b. Or create canvas with name, wich contains "gl". // 2. create TGLParametricEquation object. // TGLParametricEquation *eq = new TGLParametricEquation("name", // "some FORMULA here - x(u, v)", // "some FORMULA here - y(u, v)", // "some FORMULA here - z(u, v)", // uMin, uMax, vMin, vMax); // where FORMULA is the same string (mathematical expression), // as in TF2, but you should use 'u' (or 'U') instead of 'x' // and 'v' (or 'V') instead of 'y'. // 3. Call equation->Draw(); // Parametric surfaces support 21 color "schemes", you can change // the color: // -place mouse cursor above surface (surface is selected in pad) // -press 's' or 'S'. gStyle->SetCanvasPreferGL(kTRUE); TCanvas *c = new TCanvas("canvas","Parametric surfaces with gl", 100, 10, 700, 700); c->SetFillColor(42); gStyle->SetFrameFillColor(42); TGLParametricEquation *p3 = new TGLParametricEquation("ob_pr", "(1+0.6*sqrt(5/(16*pi))*(3*cos(u)*cos(u)-1))*sin(u)*cos(v)", "(1+0.6*sqrt(5/(16*pi))*(3*cos(u)*cos(u)-1))*sin(u)*sin(v)", "(1+0.6*sqrt(5/(16*pi))*(3*cos(u)*cos(u)-1))*cos(u)", 0, TMath::Pi(), 0, TMath::TwoPi()); p3->SetConstrained(1); p3->Draw(); // TEveManager::Create(); // TEvePlot3D *x = new TEvePlot3D("test"); // x->SetPlot(p3,""); // gEve->AddElement(x); // TEveArrow *ozz = new TEveArrow(1., 0., 0., 0, 0., 0.); // ozz->SetMainColor(kRed); // gEve->AddElement(ozz); // TEveArrow *zoz = new TEveArrow(0., 1., 0., 0, 0., 0.); // zoz->SetMainColor(kGreen); // gEve->AddElement(zoz); // TEveArrow *zzo = new TEveArrow(0., 0., 1., 0, 0., 0.); // zzo->SetMainColor(kBlue); // x->RefMainTrans().Scale(0.8, 0.8, 1.2); // gEve->AddElement(zzo); // gEve->Redraw3D(kTRUE); // gEve->GetDefaultGLViewer()->RequestDraw(); }