Show rendering of parametric surfaces.
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:
- Create canvas, which support OpenGL drawing (two ways):
- Call gStyle->SetCanvasPreferGL(kTRUE)
- Or create canvas with name, wich contains "gl".
- create TGLParametricEquation object.
"some FORMULA here - x(u, v)",
"some FORMULA here - y(u, v)",
"some FORMULA here - z(u, v)",
uMin, uMax, vMin, vMax);
A parametric surface is a surface defined by a parametric equation, involving two parameters (u,...
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'.
- 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'.
{
if (u < Pi()) {
dst.
X() = 6 * Cos(u) * (1. + Sin(u)) +
r * Cos(u) * Cos(
v);
dst.
Y() = 16 * Sin(u) +
r * Sin(u) * Cos(
v);
} else {
dst.
X() = 6 * Cos(u) * (1. + Sin(u)) +
r * Cos(
v + Pi());
}
}
void glparametrics2()
{
TCanvas *
c =
new TCanvas(
"canvas",
"Parametric surfaces with gl", 100, 10, 700, 700);
"1.2 ^ v * sin(u) ^ 2 * sin(v)",
"1.2 ^ v * sin(u) * cos(u)",
"1.2 ^ v * sin(u) ^ 2 * cos(v)",
"cos(u) / (sqrt(2) + sin(v))",
"sin(u) / (sqrt(2) + sin(v))",
"1. / (sqrt(2) + cos(v))",
klein_bottle,
"v * cos(u)",
"v * sin(u)",
"u",
-3., 3.,
-3., 3.);
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TStyle * gStyle
3 component (x/y/z) vertex class.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
constexpr Double_t TwoPi()
- Author
- Timur Pocheptsov
Definition in file glparametrics2.C.