Tom and Ballard: Thanks for the prompt reply. I integrated Tom's suggested code into the procedure that I'm developing and ran a test case. But I got an error message: Data step stopped due to looping. The entire code is below. Ultimate goal of code is dataset that looks like: Tx Ty k..........extended to include a separate column of k values for each Station -10 -10 ( 1 or 0)....... . . . 10 10 (1 or 0).......... You've already helped a great deal and thanks for that. I hope you can help me over this last hurdle. Gene data TIST7;
keep Tx Ty k;
/*Create Temporary Arrays*/
/*data _null_;*/
array _station(22) $20 _temporary_;
array xyz(5,22) _temporary_;
if _n_=1 then do i=1 to nobs;
set psolib.cameras nobs=nobs;
_station(i)=station;
xyz(1,i)=xpos;
xyz(2,i)=ypos;
xyz(3,i)=xhat;
xyz(4,i)=yhat;
xyz(5,i)=zhat;
end;
/*Test of Camera location and vector data from temporary array*/
/* 3D Unit Vector of Camera*/
xhat=xyz(3,1);
yhat=xyz(4,1);
zhat=xyz(5,1);
/*Camera Location*/
Cx=xyz(1,1);
Cy=xyz(2,1);
Cz=0;
/*Set parameters for Target grid dimensions*/
Txmin=-10; Txmax=10; nx=1;
Tymin=-10; Tymax=10; ny=1;
dx=(Txmax-Txmin)/(nx);
dy=(Tymax-Tymin)/(ny);
/*Start loop through Targets and initialize k-coverage*/
/*Creates separate grid for each camera--not exactly what I want but possibly useful*/
do Ty=Tymin to Tymax by dy;
do Tx=Txmin to Txmax by dx;
k=0; /*Initialize k-coverage to 0)*/
/*Create Target Vector from Camera to target (at 100km altitude) in 3D Cartesian grid*/
CTx=Tx-Cx;
CTy=Ty-Cy;
CTz=100-Cz;
/*Calculate distance from Camera to Target in 3 Dimensions*/
CTdist=sqrt(CTx**2+CTy**2+Ctz**2);
/*Calculate Angle between Unit Vector and Target Vector*/
SepAngle=arcos(((xhat*CTx)+(yhat*CTy)+(zhat*CTz))
/(sqrt(CTx**2 + CTy**2 + CTz**2)*sqrt(xhat**2 +yhat**2 + zhat**2)))*(180/constant('pi'));
/*Test Angle against FoV/2 and Test distance to target*/
if Sepangle LE 88/2 and CTdist<200 then k=1; /*Set k-coverage to 1 if Target within FoV*/
output;
end;
end;
run;
... View more