JavaScript Source Code 3000: Calculators: Straight Distance
Straight Distance
Enter a coordinate pair for each the starting and ending points according to the Cartesian coodinate system. The script will calculate the straight line distance between the two points.
Distance Calculator: From point A to point B
Point A
Point B
(xA,
yA)
(xB,
yB)
JavaScript Source Code 3000: Calculators: Straight Distance
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- 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">
<!-- Original: Jay Kimmel (jaykimmel@bigplanet.com) -->
<!-- Web Site: http://www.jkimmel.com -->
<! >
<! >
<!-- 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 -->
Wyszukiwarka
Podobne podstrony:
Tata Steel 5015 11 So acorta distanciasRick Wilber Straight Changes [html]1801?sign Analysis of Fixed Pitch Straight Bladed Vertical Axis Wind Turbines07b E65 Park Distance Controlgreys anatomy 213 hdtv lol special straight to the heartHallus, Tak Force Over Distance (v1 0)Blur No Distance Left to Rundistance22?5 Park Distance Control07 Train In the DistanceStraightforward Progress Test 1 IntermediateAl Past [Distant Cousin 02] Repatriation (html)Developing Your Intuition With Distant Reiki And Muscle Testdistance speed timewięcej podobnych podstron