hexagon logo

Polar angle of scan hits

Just a few code to calculate the polar angle of scan hits, waiting for the "PA" extension on them... (in Z plane, has to be changed in other ones)

ASSIGN/PI=ACOS(-1)
ASSIGN/V1=ATAN(SCN1.HIT[1..SCN1.NUMHITS].Y/SCN1.HIT[1..SCN1.NUMHITS].X)
ASSIGN/V2=((SCN1.HIT[1..SCN1.NUMHITS].X/ABS(SCN1.HIT[1..SCN1.NUMHITS].X))-1)*(-PI/2)
ASSIGN/V3=(((V1+V2)-ABS(V1+V2))/((V1+V2)-ABS(V1+V2)))*2*PI
ASSIGN/P_A=RAD2DEG(V1+V2+V3)


V1 is an array of angles in rad, between -pi/2 and pi/2 (it comes from a ATAN !)
V2 is an array of 0 and -2 * (-PI/2) : If X is positive, no change, if X is negative, add PI to the angle.
V3 is an array of 0 and 1*2PI : If angle is negative, then add 2*PI to get a value between 0 and 2PI
P_A is an array of angles in degrees between 0 and 360.

Happy week-end, all !

: Does that count ? Wink