Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
54
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 showMidPoint(){
  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.             midpoint = findMidPoint(x1, y1, x2, y2);
  12.             document.getElementById("setme").innerHTML = midpoint.xm;
  13.             document.getElementById("setme1").innerHTML = midpoint.ym;
  14.     }
  15.  
  16.  
  17.  
  18. //Algebraic Functions
  19. /* findSlopeStraight ID:A1 - Find the slope of a straight line using two points on the line.
  20.  * @param x1 - x coordinate of first point
  21.  * @param y1 - y coordinate of first point
  22.  * @param x2 - x coordiante of second coordinate
  23.  * @param y2 - y coordinate of second coordinate
  24.  */
  25. function findSlopeStraight(x1, y1, x2, y2){
  26.    return ((y2-y1)/(x2-x1));
  27. }
  28.  
  29.    
  30. /* findDistance ID:A2 - Find the distance of two points.
  31.  * @param x1 - x coordinate of first point
  32.  * @param y1 - y coordinate of first point
  33.  * @param x2 - x coordiante of second coordinate
  34.  * @param y2 - y coordinate of second coordinate
  35.  */
  36. function findDistance(x1, y1, x2, y2){
  37.     return Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
  38. }
  39.    
  40. /* findMidpoint ID:A3 - Finds the midpoint of two points.
  41.  * @param x1 - x coordinate of first point
  42.  * @param y1 - y coordinate of first point
  43.  * @param x2 - x coordiante of second coordinate
  44.  * @param y2 - y coordinate of second coordinate
  45. * */     
  46. function findMidPoint(x1, y1, x2, y2){
  47.     return {"xm": ((x1+x2)/2), "ym":((y1+y2)/2)};
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement