PDA

View Full Version : What's wrong with this?


Roosterman3000
05-09-2003, 05:38 AM
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

A1ien51
05-09-2003, 05:43 AM
You want to use degrees, and the Math function uses radians

You need to convert it

Multiply degrees by PI/180

Roosterman3000
05-09-2003, 05:45 AM
How do I set that up if you have a quick second. I appreciate the quick feedback



Rooster

A1ien51
05-09-2003, 05:55 AM
I see you posted this on other forums....lol

+'<td>'+Math.sin(mDegrees[i]*Math.PI/180)+'</td>'