Click to See Complete Forum and Search --> : What's wrong with this?


Roosterman3000
05-08-2003, 11:40 PM
I have been trying to get this to turn out right but I keep getting some negative numbers, I think I may have done something wrong and would like to know from some of you if you see any problems. Thanks

<HTML>
<HEAD>
<SCRIPT>
<!--Hide from non-javascript browsers
var mDegrees = new Array(0,15,30,45,60,75,90,105,120)
var mStr = '<TABLE border="1" cellpadding="3" cellspacing="3">'
+'<tr><td>Degrees</td><td>Sine</td><td>Cosine</td></tr>'
for (var i=0;
i<mDegrees.length;i++){
mStr+='<tr>'
+'<td>'+mDegrees[i]+'</td>'
+'<td>'+Math.sin(mDegrees[i])+'</td>'
+'<td>'+Math.cos(mDegrees[i])+'</td>'
+'</tr>'
}
mStr+='</TABLE>'
document.write(mStr)
//Stop Hiding-->
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>



Just give me a shout back thanks...

Rooster

havik
05-09-2003, 12:00 AM
Check this link, it appears negative values are correct values.

http://javascript.internet.com/miscellaneous/trigonomic-ratios.html


Havik

Roosterman3000
05-09-2003, 12:03 AM
appreciate it, I thought everything looked great but why would there be negatives you know... wierd. Thanks for taking a look


Rooster

A1ien51
05-09-2003, 12:07 AM
hmmm, CF.....Answer...??

havik
05-09-2003, 12:10 AM
I found another link describing the javascript math object. Apparently, the parameter sent to the functions math.cos and math.sin are considered to be radians, not degrees. Check the link to determine how to change the value from radians to degrees.

http://www.comptechdoc.org/independent/web/cgi/javamanual/javamath.html

Havik

A1ien51
05-09-2003, 12:11 AM
I posted that answer in another forum.......

Most calculators use radians too....hmmm

Roosterman3000
05-09-2003, 12:21 AM
Yeah but this forum usually posts a little fast but you did answer my question and I thank you.

Rooster