TImageDump error (2)

From: OKUMURA, Akira <oxon_at_icrr.u-tokyo.ac.jp>
Date: Tue, 13 Feb 2007 03:19:18 -1000


Hello ROOTers again,

I have one more problem on TImageDump. The attached program detect a floating exception error while running.

  $ ./scscm_comb2

If I change the value of 'double azi' in the code (ex. 167.), it runs as I expected. In addition if I change the line width of TPolyLine to 1, it runs too.

I looked the source code of
$ROOTSYS/asimage/src/libAfterImage/draw.c

There are divisions by 'int k' in the function 'clip_line'. I guess this is the reason of the error because nobody checks if k!=0.

The attached code was rather shorter than my original code. But it may be still long to find the position of potential of an error. Originally the code does conversion of CCD image coordinate from 320x240 in unit of pixels to (alt [-10:90], azi [-180:180]) in unit of degree. Process of reading CCD data was removed from the code.

Sincerely,

OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
Institute for Cosmic Ray Research, University of Tokyo 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan Phone/Fax : +81 4-7136-3153
Skype : okumura.akira


#include <TImageDump.h>
#include <TPolyLine.h>
#include <TCanvas.h>
#include <TVector3.h>

using namespace std;

void DrawFITS();

const int kWidth = 320;
const int kHeight = 240;
const double kPx2Deg = 29./kWidth;
const int kStep = 4;

double alt = 19. + 59/60. + 52/3600.;
double azi = 167. + 59/60. + 51/3600.;

int main()
{

   TCanvas can("can", "can", 360*3+4, 100*3+28);

   can.SetLeftMargin(0);
   can.SetRightMargin(0);
   can.SetTopMargin(0);
   can.SetBottomMargin(0);

   DrawFITS();

   TImageDump dump("test.gif");
   can.Paint();
   dump.Close();

   return 0;
}

//




void DrawFITS()
{

   const double kDeg2Rad = TMath::Pi()/180.;    const double kRad2Deg = 180./TMath::Pi();

   for(int y=kStep; y<kHeight; y+=kStep){

     for(int x=kStep; x<kWidth; x+=kStep){
       double x1 = (x  -kWidth/2.)*kPx2Deg;
       double x2 = (x+kStep-kWidth/2.)*kPx2Deg;
       double y1 = (y  -kHeight/2.)*kPx2Deg;
       double y2 = (y+kStep-kHeight/2.)*kPx2Deg;
       TVector2 vec2[4];
       vec2[0] = TVector2(x1, y1);
       vec2[1] = TVector2(x2, y1);
       vec2[2] = TVector2(x2, y2);
       vec2[3] = TVector2(x1, y2);
       double theta[4], phi[4];
       TVector3 vec3[4];
       for(int j=0; j<4; j++){
	theta[j] = vec2[j].Mod()*kDeg2Rad;
	phi[j] = vec2[j].Phi();
	vec3[j].SetMagThetaPhi(1, theta[j], phi[j]);
	vec3[j].RotateZ(-90*kDeg2Rad);
	vec3[j].RotateY((90-alt)*kDeg2Rad);
       } // j

       double px[5], py[5];
       for(int j=0; j<4; j++){
	px[j] = vec3[j].Phi()*kRad2Deg + azi;
	py[j] = 90 - vec3[j].Theta()*kRad2Deg;
       } // j

       if(px[0]<-180 && px[1]<-180 && px[2]<-180 && px[3]<-180){
	px[0] += 360.;
	px[1] += 360.;
	px[2] += 360.;
	px[3] += 360.;
       } else if(px[0]>180 && px[1]>180 && px[2]>180 && px[3]>180){
	px[0] -= 360.;
	px[1] -= 360.;
	px[2] -= 360.;
	px[3] -= 360.;
       } // if

       if(py[1]<py[2]){
	for(int j=0; j<4; j++){
	  py[j] = 180. - py[j];
	} // j
       } // if

       px[4] = px[0];
       py[4] = py[0];

       // deg to pixel conversion
       for(int i=0; i<5; i++){
	px[i] = px[i]/360. + 0.5;
	py[i] = (py[i]+10)/100.;
       } // i

       TPolyLine* pol = new TPolyLine(5, px, py);
       pol->SetLineWidth(2);
       pol->Draw();
     } // x

   } // y
} Received on Tue Feb 13 2007 - 14:20:55 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 13 2007 - 17:50:01 CET