(*

Title:   Vectors
Author:  William M. Farmer
Revised: 03-OCT-2002
  
Description: Compares two two-dimensional vectors represented as
pairs of real numbers.

Interface:

INTERFACE Vectors;
  PROCEDURE Compare(x1,y1,x2,y2: REAL): INTEGER;
END Vectors.

*)


MODULE Vectors;

(* Single Interface procedure *)

PROCEDURE Compare*(x1,y1,x2,y2: REAL): INTEGER;
(* (x1,y1) and (x2,y2) represent vectors with real number cartesian 
   coordinates. *)
BEGIN
  IF (x1 = x2) & (y1 = y2) THEN
    RETURN 0 (* (x1,y1) and (x2,y2) are identical. *)
  ELSIF x1*x2 + y1*y2 =0 THEN
    RETURN 1 (* (x1,y1) and (x2,y2) are orthogonal. *)
  ELSIF ((x1 = 0) & (x2 = 0)) OR 
        ((y1 = 0) & (y2 = 0)) OR 
        ((x2 # 0) & (y2 # 0) & (x1/x2 = y1/y2)) THEN
    RETURN 2 (* (x1,y1) and (x2,y2) are collinear. *)
  ELSE 
    RETURN 3 (* (x1,y1) and (x2,y2) are not identical, orthogonal, 
                 or collinear. *)
  END
END Compare;

END Vectors.

