PEF524 Posted February 1, 2007 Share Posted February 1, 2007 hey... im trying to make a loop using all of the degrees 0-360 and displaying with the Sine of each of those is EX) Angle Sin 0 0 1 .01745 2 .0349 etc etc ... this is what im doing and it is not working, can anyone help? <?php $sin=sin($i); $i=deg2rad($i); for($i=0; $i<=360; $i=$i+1) echo "$sin"; ?> thanks! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 <?php for($i=0; $i<=360; $i=$i+1) $d=deg2rad($i); $sin=sin($d); echo "$sin"; ?> You have some things backwards, try that? Quote Link to comment Share on other sites More sharing options...
PEF524 Posted February 1, 2007 Author Share Posted February 1, 2007 ugh... thanks but that didn't work for me for whatever reason its not looping through all of the degrees for the code you gave me it just said "-2.44921270764E-16" I'll keep playing around with it Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 try starting at 1 instead of 0? Quote Link to comment Share on other sites More sharing options...
PEF524 Posted February 1, 2007 Author Share Posted February 1, 2007 still no luck, even with changing 0 to 1 i basically just want a list of all the sines of all the angles without having to write out the sin() function for each one... anyone else have any ideas? ??? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 What happens if you just do: print sin(deg2rad(1)); Does that work? The sin of 1 degree, is very small, right, it's almost 0, yeah? (or is that cos?) So it should print a very small number. You may have to format it in order to get it to look right. Quote Link to comment Share on other sites More sharing options...
dgiberson Posted February 1, 2007 Share Posted February 1, 2007 echo "<table><tr><td>Angle</td><td>Sin(x)</td></tr>"; for ($i=0;$i<=360;$i++) { $d = deg2rad($i); $sin = sin($d); echo "<tr><td>$i</td><td>$sin</td></tr>"; } echo "</table>"; Quote Link to comment Share on other sites More sharing options...
PEF524 Posted February 1, 2007 Author Share Posted February 1, 2007 thanks dgiberson and jesirose, got it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.