# Bhaskara sin angle reduction # pretty print from autoindent and ased editor # Bhaskara sine formula and extensions into TCL # written on Windows XP on TCL # working under TCL version 8.5.6 # gold on TCL WIKI , 10jan2017 # angle reduction from k-N*360 degrees, -360> output angle < 360 proc sin_angle_reduction {aa } {set pi [ expr { acos(-1) } ]; expr {abs($aa)>360? asin ( sin($aa*($pi/180.)) ) * (180./$pi) : $aa } } puts " sin angle reduction [ sin_angle_reduction 30. ] " puts " sin angle reduction [ sin_angle_reduction 760. ] " puts " sin angle reduction [ sin_angle_reduction -760. ] " puts " timing sin angle reduction [ time {sin_angle_reduction -760. } 100 ] " puts " timing degree_reduction [ degree_reduction 900005.0000000000001 ] " puts " timing degree_reduction [ time {degree_reduction 900055.0000000000001 } 100 ] " # sin angle reduction 30.0 #sin angle reduction 40.00000000000003 #sin angle reduction -40.00000000000003 #timing sin angle reduction 5.7 microseconds per iteration #timing degree_reduction 4.98 microseconds per iteration