Have you ever thought of constructing trigonometric tables? To construct a table for an angle starting from 0 degrees and continuing to 360 degrees using three basic trigonometric functions and their inverses (with $x as the variable): sin(deg2rad($x)) cos(deg2rad($x)) tan(deg2rad($x)) You will need to iterate going from 0 degrees to 360 degrees using a WHILE loop. You will need to convert $x to radians, since by default trigonometric functions evaluate angles as radians. You can accomplish this using the function: Deg2rad(); Below is the complete script required to generate the trigonometric table for the three functions (sine, cosine and tangent) and well as their inverses (cotangent, secant, and cosecant) <?php echo '<table width=100% border=1>'; echo '<tr><td><b>Angle in Degrees</b></td><td><b>Sine</b></td><td><b>Cosine</b></td> $i=1; while ($i<=360) { $x=$i++; echo '<tr>'; echo '<td>'.$x.'</td>'; echo '<td>'.sin(deg2rad($x)).'</td>'; echo '<td>'.cos(deg2rad($x)).'</td>'; echo '<td>'.tan(deg2rad($x)).'</td>'; echo '<td>'.(1/tan(deg2rad($x))).'</td>'; echo '<td>'.(1/cos(deg2rad($x))).'</td>'; echo '<td>'.(1/sin(deg2rad($x))).'</td>'; echo '</tr>'; } echo '</table>'; ?> The screen shot below is the trigonometric table when viewed in a browser:
You can also extend the above application not only to trigonometry but to other important engineering tables like logarithmic tables, steam tables, etc.
blog comments powered by Disqus |
|
|
|
|
|
|
|