30 Double_t amplitude = par[0] * (
cos(tpi_l *
sqrt(x_p2 + ym_p2)) + par[3] *
cos(tpi_l *
sqrt(x_p2 + yp_p2)));
31 return amplitude * amplitude;
40 for (
Int_t i = 0; i < 10; i++) {
43 Double_t intens = interference(xint, par);
44 if (intens > maxintens)
54 TCanvas *
c1 =
new TCanvas(
"waves",
"A double slit experiment", 300, 40, 1004, 759);
55 c1->Range(0, -10, 30, 10);
57 TPad *pad =
new TPad(
"pr",
"pr", 0.5, 0, 1., 1);
58 pad->
Range(0, -10, 15, 10);
61 const Int_t colNum = 30;
62 Int_t palette[colNum];
63 for (
Int_t i = 0; i < colNum; i++) {
64 Float_t level = 1. * i / colNum;
73 TF2 *f0 =
new TF2(
"ray_source", interference, 0.02, 15, -8, 8, 4);
81 title.
DrawLatex(1.6, 8.5,
"A double slit experiment");
84 graph->SetFillColor(0);
85 graph->SetFillStyle(1001);
86 graph->SetLineWidth(0);
87 graph->SetPoint(0, 0., 0.1);
88 graph->SetPoint(1, 14.8, 8);
89 graph->SetPoint(2, 0, 8);
90 graph->SetPoint(3, 0, 0.1);
94 graph->SetFillColor(0);
95 graph->SetFillStyle(1001);
96 graph->SetLineWidth(0);
97 graph->SetPoint(0, 0, -0.1);
98 graph->SetPoint(1, 14.8, -8);
99 graph->SetPoint(2, 0, -8);
100 graph->SetPoint(3, 0, -0.1);
107 line =
new TLine(15, 0 - 0.5 *
d + 0.2, 15, 0 + 0.5 *
d - 0.2);
111 line =
new TLine(15, 0 + 0.5 *
d + 0.2, 15, 10);
117 TF2 *finter =
new TF2(
"interference", interference, 0.01, 14, -10, 10, 4);
122 finter->
Draw(
"samecol");
128 Float_t r = 0.5 * lambda, dr = lambda;
129 for (
Int_t i = 0; i < 16; i++) {
130 arc.
DrawArc(0, 0.5 *
d,
r, 0., 360.,
"only");
131 arc.
DrawArc(0, -0.5 *
d,
r, 0., 360.,
"only");
137 TF2 *fresult =
new TF2(
"result",
result, 14, 15, -10, 10, 4);
142 fresult->
Draw(
"samecol");
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
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
R__EXTERN TStyle * gStyle
virtual TArc * DrawArc(Double_t x1, Double_t y1, Double_t radius, Double_t phimin=0, Double_t phimax=360, Option_t *option="")
Draw this arc with new coordinates.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
virtual void SetParameters(const Double_t *params)
A 2-Dim function with parameters.
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
Set the number and values of contour levels.
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
void Draw(Option_t *option="") override
Draw this function with its current attributes.
A TGraph is an object made of two arrays X and Y with npoints each.
To draw Mathematical Formula.
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
Use the TLine constructor to create a simple line.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
The most important graphics class in the ROOT system.
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Set world coordinate system for the pad.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
RVec< PromoteType< T > > cos(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.