Hi,
Everytime i run the programme, it shows'Invalid floating point operation' at the line, Homogeneous:=1-((Nraysmax-Nraysmin)/(Nraysmax+Nraysmin));. Can someone tell me why?
Following is the coding.
procedure TForm1.Homo(var homogeneous:double);
var
i,Nrays,ibin,jbin:integer;
Nxpoints,Nypoints,Nraysmax,Nraysmin:integer;
xrange,yrange,xbin,ybin,Xmin,Xmax,Ymin,Ymax:double;
begin
Xmin:=0; //set initial point for x
xrange:=1;
yrange:=1; //set the range of area
Nxpoints:=3; //set how many area it will be divided to
Nypoints:=3; //if 100, then nxpoints & nypoints =11, if 10000 = 101
Nraysmax:=0;
Nraysmin:=Nofrays; //initialise
Homogeneous:=0;
Nrays:=0;
for ibin := 1 to Nxpoints-1 do
begin
xbin:=(xrange*ibin)/(Nxpoints-1);
Xmax:=xbin; //set the next point for x
Ymin:=0;
for jbin := 1 to Nypoints-1 do
begin
ybin:=(yrange*jbin)/(Nypoints-1);
Ymax:=ybin; //set the next point for y
for i := 0 to Nofrays - 1 do
begin
if (Newrayposition[i,0]>=Xmin)and(Newrayposition[i,0]<=Xmax)and(Newrayposition[i,1]>=Ymin)and(Newrayposition[i,1]<=Ymax)and(Newrayposition[i,2]=1.4)then
Inc(Nrays);
end;
if Nrays>Nraysmax then
Nraysmax:=Nrays; //set max Nrays
if Nrays<Nraysmin then
Nraysmin:=Nrays; //set min Nrays
Nrays:=0;
//ShowMessage('Nraysmax = '+FloatToStr(Nraysmax));
//ShowMessage('Nraysmin = '+FloatToStr(Nraysmin));
Ymin:=Ymax;
end;
Xmin:=Xmax;
end;
Homogeneous:=1-((Nraysmax-Nraysmin)/(Nraysmax+Nraysmin)); //calculate homogeneous
ShowMessage('Homogeneous = '+FloatToStr(Homogeneous));
end;
Everytime i run the programme, it shows'Invalid floating point operation' at the line, Homogeneous:=1-((Nraysmax-Nraysmin)/(Nraysmax+Nraysmin));. Can someone tell me why?
Following is the coding.
procedure TForm1.Homo(var homogeneous:double);
var
i,Nrays,ibin,jbin:integer;
Nxpoints,Nypoints,Nraysmax,Nraysmin:integer;
xrange,yrange,xbin,ybin,Xmin,Xmax,Ymin,Ymax:double;
begin
Xmin:=0; //set initial point for x
xrange:=1;
yrange:=1; //set the range of area
Nxpoints:=3; //set how many area it will be divided to
Nypoints:=3; //if 100, then nxpoints & nypoints =11, if 10000 = 101
Nraysmax:=0;
Nraysmin:=Nofrays; //initialise
Homogeneous:=0;
Nrays:=0;
for ibin := 1 to Nxpoints-1 do
begin
xbin:=(xrange*ibin)/(Nxpoints-1);
Xmax:=xbin; //set the next point for x
Ymin:=0;
for jbin := 1 to Nypoints-1 do
begin
ybin:=(yrange*jbin)/(Nypoints-1);
Ymax:=ybin; //set the next point for y
for i := 0 to Nofrays - 1 do
begin
if (Newrayposition[i,0]>=Xmin)and(Newrayposition[i,0]<=Xmax)and(Newrayposition[i,1]>=Ymin)and(Newrayposition[i,1]<=Ymax)and(Newrayposition[i,2]=1.4)then
Inc(Nrays);
end;
if Nrays>Nraysmax then
Nraysmax:=Nrays; //set max Nrays
if Nrays<Nraysmin then
Nraysmin:=Nrays; //set min Nrays
Nrays:=0;
//ShowMessage('Nraysmax = '+FloatToStr(Nraysmax));
//ShowMessage('Nraysmin = '+FloatToStr(Nraysmin));
Ymin:=Ymax;
end;
Xmin:=Xmax;
end;
Homogeneous:=1-((Nraysmax-Nraysmin)/(Nraysmax+Nraysmin)); //calculate homogeneous
ShowMessage('Homogeneous = '+FloatToStr(Homogeneous));
end;