#include #include #include #include #include void Rotate(float angle){ TH2F * h2 = (TH2F*)gROOT->FindObject("h2"); if(h2)delete h2; h2 = new TH2F("h2", "h2", 400, 0.0, 399.0, 399, 0.0, 399.0); TH2F * ht = (TH2F*)gROOT->FindObject("ht"); if(ht)delete ht; ht = new TH2F("ht", "ht", 400, 0.0, 399.0, 399, 0.0, 399.0); TH2F * ha = (TH2F*)gROOT->FindObject("ha"); if(ha)delete ha; ha = new TH2F("ha", "ha", 400, 0.0, 399.0, 399, 0.0, 399.0); Int_t nx = h2->GetNbinsX(); Int_t ny = h2->GetNbinsY(); //origo is in 400/2, 400/2 Int_t x0 = 200; Int_t y0 = 200; for(Int_t i = 0; i < nx; i++){ h2->Fill(x0, i); } for(Int_t j = 0; j < ny; j++){ h2->Fill(j, y0); } angle = angle * TMath::Pi()/180.0; //so input can be in degrees for(Int_t it = 0; it < 90; it++){ angle = angle+(1.0*TMath::Pi()/180.0);//increase angle by 1 degree cout << "it: " << it << endl;//where are we? float t = 0.0; ht->Reset(); for(Int_t i = 0; i < nx; i++){ for(Int_t j = 0; j < ny; j++){ TVector3 v(i+1 - x0, j+1 - y0, 0); t = h2->GetCellContent(i+1, j+1); v.RotateZ(angle); ht->Fill(v.X() + x0, v.Y() + y0, t); } } Double_t *array1 = new Double_t[nx*ny]; for (Int_t j=0;jGetCellContent(i+1,j+1); } } TImage *img1 = TImage::Create(); img1->SetImage(array1,nx,ny,gHistImagePalette); img1->WriteImage("animrot.gif+"); delete img1; } }