Jump to content

[SOLVED] "for" loops and "sin()"


PEF524

Recommended Posts

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!

 

 

Link to comment
https://forums.phpfreaks.com/topic/36585-solved-for-loops-and-sin/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.