Начало
Калькуляторы
Прямое Расстояние
Внесите в координационную пару для каждого старт и конечные пункты согласно Декартовской coodinate системе. скрипт вычислит расстояние прямой линии между двумя пунктами.
Distance Calculator: From point A to point B
Point A
Point B
(x
A
,
y
A
)
(x
B
,
y
B
)
JavaScript Calculators: прямое расстояние
<!-- TWO STEPS TO INSTALL STRAIGHT DISTANCE: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin function distance(form) { var x1 = eval(form.x1.value); var y1 = eval(form.y1.value); var x2 = eval(form.x2.value); var y2 = eval(form.y2.value); var xdiff = x2 - x1; var ydiff = y2 - y1; form.answer.value = Math.pow((xdiff * xdiff + ydiff * ydiff), 0.5); } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <form> <table border=3 cellspacing=2 cellpadding=5> <tr> <td colspan=4 align=center>Distance Calculator: From point A to point B</td> </tr> <tr> <td colspan=2 align=center>Point A</td> <td colspan=2 align=center>Point B</td> </tr> <tr> <td align=center>(x<sub>A</sub>,</td> <td align=center>y<sub>A</sub>)</td> <td align=center>(x<sub>B</sub>,</td> <td align=center>y<sub>B</sub>)</td> </tr> <tr> <td align=center><input type=text name=x1 size=5></td> <td align=center><input type=text name=y1 size=5></td> <td align=center><input type=text name=x2 size=5></td> <td align=center><input type=text name=y2 size=5></td> </tr> <tr> <td colspan=4 align=center><input type=button value="Solve Distance" onClick="distance(this.form)"></td> </tr> <tr> <td colspan=4 align=center><input type=text name=answer size=20></td> </tr> </table> </form> </center> <!-- Script Size: 1.80 KB -->