debug--
Check cos>=1 replaced to cos>=.99