Today some success with the conversion of Cartesian coordinates into polar coordinates in SAS. Another short post today, but it appears all the transformation action takes place in the initial data step — the transformations I used in the first data step is as follows:
data boids;
infile ‘C:\tempy\boidposition_out.txt’;
input Bird_ID Radius Timestep
B_Pos_x B_Pos_y B_Pos_z
B_Vel_x B_Vel_y B_Vel_z
F_Pos_x F_Pos_y F_Pos_z
F_Vel_x F_Vel_y F_Vel_z
;
vel_theta = b_vel_y/b_vel_x;
vel_atan_theta = (atan(vel_theta) * (180/3.14));
if (b_vel_x > 0) and (b_vel_y < 0) then vel_atan_theta = vel_atan_theta + 360;
if (b_vel_x < 0) and (b_vel_y > 0) then vel_atan_theta = vel_atan_theta + 180;
if (b_vel_x < 0) and (b_vel_y < 0) then vel_atan_theta = vel_atan_theta + 180;
This means on the initial data upload we create two new columns called vel_theta and vel_atan_theta. We then have three IF statements to modify the data as required. This generates output with 17 columns of information. The next stage is to calculate the standard deviation for the flock, based on the above syntax — and this will be tomorrow’s task!