Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Math Tools Library V0.1
  2.  * Copyright 2011 funstuff234 apps
  3.  */
  4.  
  5. //DOM Test
  6. function showDistance(){
  7.             x1 = document.getElementById("x1").value;
  8.             y1 = document.getElementById("y1").value;
  9.             x2 = document.getElementById("x2").value;
  10.             y2 = document.getElementById("y2").value;
  11.             distance = findSlopeStraight(x1, y1, x2, y2);
  12.             document.getElementById("setme").innerHTML = distance;
  13.     }
  14.  
  15.  
  16.  
  17. //Algebraic Functions
  18. /* findSlopeStraight ID:A1 - Find the slope of a straight line using two points on the line.
  19.  * @param x1 - x coordinate of first point
  20.  * @param y1 - y coordinate of first point
  21.  * @param x2 - x coordiante of second coordinate
  22.  * @param y2 - y coordinate of second coordinate
  23.  */
  24. function findSlopeStraight(x1, y1, x2, y2){
  25.    return ((y2-y1)/(x2-x1));
  26.     }
  27.  
  28.    
  29. /* findDistance ID:A2 - Find the distance of two points.
  30.  * @param x1 - x coordinate of first point
  31.  * @param y1 - y coordinate of first point
  32.  * @param x2 - x coordiante of second coordinate
  33.  * @param y2 - y coordinate of second coordinate
  34.  */
  35. function findDistance(x1, y1, x2, y2){
  36.     return Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement