Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Math Tools Library V0.1
- * Copyright 2011 funstuff234 apps
- */
- //DOM Test
- function showDistance(){
- x1 = document.getElementById("x1").value;
- y1 = document.getElementById("y1").value;
- x2 = document.getElementById("x2").value;
- y2 = document.getElementById("y2").value;
- distance = findSlopeStraight(x1, y1, x2, y2);
- document.getElementById("setme").innerHTML = distance;
- }
- //Algebraic Functions
- /* findSlopeStraight ID:A1 - Find the slope of a straight line using two points on the line.
- * @param x1 - x coordinate of first point
- * @param y1 - y coordinate of first point
- * @param x2 - x coordiante of second coordinate
- * @param y2 - y coordinate of second coordinate
- */
- function findSlopeStraight(x1, y1, x2, y2){
- return ((y2-y1)/(x2-x1));
- }
- /* findDistance ID:A2 - Find the distance of two points.
- * @param x1 - x coordinate of first point
- * @param y1 - y coordinate of first point
- * @param x2 - x coordiante of second coordinate
- * @param y2 - y coordinate of second coordinate
- */
- function findDistance(x1, y1, x2, y2){
- return Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement