FUNCTION line2d, x1, y1, x2, y2, NO_PAR_CHECK = no_par_check
; Description: This function calculates the y-intercept and gradient of a straight line passing
; through the points A and B with coordinates "(x1,y1)" and "(x2,y2)", respectively.
; The equation of the straight line used is:
;
; y - y1 = ((y2 - y1)/(x2 - x1)) * (x - x1)
;
; This equation is then rearranged into the form:
;
; y = m*x + c
;
; and the y-intercept c and gradient m are returned to the user as a 2-element
; vector.
;
; Input Parameters:
;
; x1 - FLOAT/DOUBLE - The x coordinate of the first point.
; y1 - FLOAT/DOUBLE - The y coordinate of the first point.
; x2 - FLOAT/DOUBLE - The x coordinate of the second point.
; y2 - FLOAT/DOUBLE - The y coordinate of the second point.
;
; Return Value:
;
; The function returns a two element vector of DOUBLES where the first and second elements are
; the y-intercept and gradient of the line, respectively. If the input parameters are not numbers
; of the correct type (and parameter checking is performed), then both the y-intercept and
; gradient are returned as zeros. In the case that the straight line joining A and B is "vertical"
; (x1 = x2), then both the y-intercept and gradient are returned as zeros. In the case that A and
; B are coincident, then again both the y-intercept and gradient are returned as zeros.
;
; Keywords:
;
; If the keyword NO_PAR_CHECK is set (as "/NO_PAR_CHECK"), then the program will not perform
; parameter checking on the input parameters, reducing program overheads.
;
; Author: Dan Bramich (dan.bramich@hotmail.co.uk)
;
; History:
;
; 09/08/2008 - Module created (dmb)
;Perform parameter checking if not instructed otherwise
;Check that "x1", "y1", "x2" and "y2" are all numbers of the correct type
;If the two points A and B are not coincident, or do not form a "vertical" straight line
;Calculate the line gradient
;Calculate the line y-intercept
;Return the straight line y-intercept and gradient as a two-element vector
;If the two points A and B are coincident, or form a "vertical" straight line, then return the
;line y-intercept and gradient as zeros