#!/usr/bin/awk -f BEGIN {print "par(a,bi,c,di),pol(x,y),rec(x,y)" print "div(a,bi,c,di)"; print "phasub(a,degree,b,degree)" } /par/{x = ($2/($2^2+$3^2))+($4/($4^2+$5^2)); y = ($3/($2^2+$3^2))+($5/($4^2+$5^2)); z = (x/(x^2+y^2)); t = (y/(x^2+y^2)); print z, t; } /pol/{x = sqrt(($2^2+$3^2)); y = (atan2($3,$2)*180)/atan2(0,-1); print x,"/_",y; } /rec/{x = $2 * cos(($3*atan2(0,-1))/180); y = $2 * sin(($3*atan2(0,-1))/180); print x,y; } /div/{x = (($2*$4)+($3*$5)); y = (($3*$4)-($2*$5)); z = ($4^2+$5^2); print x/z,"i",y/z; } /phasub/ { x = $2 * cos(($3*atan2(0,-1))/180); y = $2 * sin(($3*atan2(0,-1))/180); z = $4 * cos(($5*atan2(0,-1))/180); t = $4 * sin(($5*atan2(0,-1))/180); a = x-z; b = y-t; print sqrt((a^2+b^2)),"/_",(atan2(b,a)*180)/atan2(0,-1); } /phaadd/ { x = $2 * cos(($3*atan2(0,-1))/180); y = $2 * sin(($3*atan2(0,-1))/180); z = $4 * cos(($5*atan2(0,-1))/180); t = $4 * sin(($5*atan2(0,-1))/180); a = x+z; b = y+t; print sqrt((a^2+b^2)),"/_",(atan2(b,a)*180)/atan2(0,-1); }