global Pi Pi =3.1415926535 print "Mean Angle( "; chr$( 34); "350,10"; chr$( 34); ") = "; using( "###.#", meanAngle( "350,10")); " degrees." ' 0 print "Mean Angle( "; chr$( 34); "90,180,270,360"; chr$( 34); ") = "; using( "###.#", meanAngle( "90,180,270,360")); " degrees." ' -90 print "Mean Angle( "; chr$( 34); "10,20,30"; chr$( 34); ") = "; using( "###.#", meanAngle( "10,20,30")); " degrees." ' 20 end function meanAngle( angles$) term =1 while word$( angles$, term, ",") <>"" angle =val( word$( angles$, term, ",")) sumSin = sumSin +sin( degRad( angle)) sumCos = sumCos +cos( degRad( angle)) term =term +1 wend meanAngle= radDeg( atan2( sumSin, sumCos)) if abs( sumSin) +abs( sumCos) <0.001 then notice "Not Available." +_ chr$( 13) +"(" +angles$ +")" +_ chr$( 13) +"Result nearly equals zero vector." +_ chr$( 13) +"Displaying '666'.": meanAngle =666 end function function degRad( theta) degRad =theta *Pi /180 end function function radDeg( theta) radDeg =theta *180 /Pi end function function atan2( y, x) if x >0 then at =atn( y /x) if y >=0 and x <0 then at =atn( y /x) +pi if y <0 and x <0 then at =atn( y /x) -pi if y >0 and x =0 then at = pi /2 if y <0 and x =0 then at = 0 -pi /2 if y =0 and x =0 then notice "undefined": end atan2 =at end function