<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Computer Science 553 Lab Pages: Lab 3: Trig Functions On The Fly</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<style>
td{text-align:center;}
.alt{background-color:#ccc;}
</style>
</head>
<body>
<h1>Table of Sines, Cosines, and Tangents</h1>
<h2>Charles P. Scott | 9092</h2>
<hr>
<script>
function addCell(row,tag,content){
var cell=document.createElement(tag);
cell.innerHTML=content;
row.appendChild(cell);
}
function addRow(tab){
var tr=document.createElement('tr');
tab.appendChild(tr);
return tr;
}
var myTable=document.createElement("table"),angleR=0,angleD=0;
myTable.setAttribute('align','center');
myTable.setAttribute('border','1');
myTable.setAttribute('cellSpacing','3');
myTable.setAttribute('cellPadding','3');
document.body.appendChild(myTable);
var hdr=addRow(myTable);
addCell(hdr,'td','Radians');
addCell(hdr,'td','Degrees');
addCell(hdr,'td','sin(x)');
addCell(hdr,'td','cos(x)');
addCell(hdr,'td','tan(x)');
for(var i=0;i < 25;i++){
var result_SinX=Math.round(Math.sin(angleR)*100000)/100000,
result_CosX=Math.round(Math.cos(angleR)*100000)/100000,
tRowC=addRow(myTable);
if((i+1)%2==0){tRowC.setAttribute('class','alt');}
addCell(tRowC,'td','<img src="images/img'+angleD+'.gif" alt="" />');
addCell(tRowC,'td',angleD+'°');
addCell(tRowC,'td',result_SinX);
addCell(tRowC,'td',result_CosX);
var resultTanX=((angleD === 90)||(angleD === 270))?"Undefined":(Math.round(Math.tan(angleR)*100000)/100000);
addCell(tRowC,'td',resultTanX);
angleR += Math.PI/12;
angleD += 15;
}
</script>
<br /><br />
<a href="javascript:history.go(-1)">[ Go Back ]</a>
</body>
</html>