»
EnglishFrenchVietnamese

Print - Geometric Properties of a Triangle - JavaScriptBank.com

Full version: jsB@nk » Calculation » Math » Geometric Properties of a Triangle
URL: http://www.javascriptbank.com/geometric-properties-of-a-triangle.html

Geometric Properties of a Triangle © JavaScriptBank.comWith this JavaScript code, you will not have to remember the complicated formulas for calculating the values of a triangle. Now this code only solves the simple values such as: area of triangle, area of largest/smallest inscribed circle, the angle between two side.However, the advantage of simplicity is it will be easy for you to understand how it work and customize it according to your needs. Things you need when use this JavaScript code is enter the values of three sides.

Full version: jsB@nk » Calculation » Math » Geometric Properties of a Triangle
URL: http://www.javascriptbank.com/geometric-properties-of-a-triangle.html



JavaScript
<script type="text/javascript">// Created by: Sandeep Gangadharan | http://sivamdesign.com/scripts/function getProp() {  var A = document.prop.A.value;  var B = document.prop.B.value;  var C = document.prop.C.value;  var S = (parseInt(A) + parseInt(B) + parseInt(C)) / 2;  var Z = parseInt((A*A)+(B*B)-(C*C))/parseInt(2*A*B);  document.prop.area.value = Math.round(Math.sqrt(S*(S-A)*(S-B)*(S-C)) * 10000) / 10000;  document.prop.lic.value = Math.round(Math.PI * (document.prop.area.value/S) * (document.prop.area.value/S) * 10000) / 10000;  document.prop.sic.value = Math.round(Math.PI * ((A*B*C)/(4*(document.prop.area.value))) * ((A*B*C)/(4*(document.prop.area.value))) * 10000) / 10000;  document.prop.ang.value = Math.round(Math.atan(Math.sqrt((1/(Z * Z))-1)) * (180/Math.PI) * 10000) / 10000;}</script>


HTML
<table border="0" cellpadding="4" cellspacing="0" bgcolor="#cccccc"><form name="prop"> <tr>  <td colspan="4" style="color: #fff; background: #000080;">    <b>Geometric Properties of a Triangle</b></font>  </td> </tr><tr>  <td>    <b>Side A: </b>  </td>  <td>    <input type="text" size="4" name="A" style="font-size: 9pt">  </td>  <td>    <b>Area of Triangle: </b>  </td>  <td>    <input type="text" size="8" name="area" disabled="disabled" style="color: #000; background: #fff; font-size: 9pt; text-align: right;">  </td> </tr> <tr>  <td>    <b>Side B: </b>  </td>  <td>    <input type="text" size="4" name="B" style="font-size: 9pt">  </td>  <td>    <b>Area of Largest Inscribed Circle: </b>  </td>  <td>    <input type="text" size="8" name="lic" disabled="disabled" style="color: #000; background: #fff; font-size: 9pt; text-align: right;">  </td> </tr> <tr>  <td>    <b>Side C: </b>  </td>  <td>    <input type="text" size="4" name="C" style="font-size: 9pt">  </td>  <td>    <b>Area of Smallest Inscribed Circle: </b>  </td>  <td>    <input type="text" size="8" name="sic" disabled="disabled" style="color: #000; background: #fff; font-size: 9pt; text-align: right;">  </td> </tr> <tr>  <td>    <input type="reset" value="Reset" style="font-size: 9pt" onClick="reset()">  </td>  <td>    <input type="button" value="Compute" style="font-size: 9pt" onClick="getProp()">  </td>  <td>    <b>Angle between A and B: </b>  </td>  <td>    <input type="text" size="8" name="ang" disabled="disabled" style="color: #000; background: #fff; font-size: 9pt; text-align: right;">  </td> </tr></form></table>