-- $Date: 2004/02/27 04:45:00 $
-- $Revision: 1.16 $
-- $Author: jcrocholl $

generic

   -- Generic type for simple numbers.
   -- Can be Integer or Float, for example.
   type Number is private;

   -- Generic value for the zero number.
   -- Can be 0 or 0.0, for example.
   Zero : Number;

   -- Convert a number to a string.
   with function To_String
     (This : in Number-- Convert this number.
     return String      -- The string representation.
     is <>;

   -- Convert a number to a string.
   with function To_String
     (This      : in Number-- Convert this number.
      Tolerance : in Number-- Tolerance level.
     return String           -- The string representation.
     is <>;

   -- Calculate the square root of a non-negative number.
   with function Sqrt
     (This : in Number-- Non-negative input value.
     return Number      -- Square root of input value.
     is <>;

   -- Minimum of two numbers.
   with function Min
     (A, B : in Number)
     return Number
     is <>;

   -- Maximum of two numbers.
   with function Max
     (A, B : in Number)
     return Number
     is <>;

   -- with function "abs"(A : in Number) return Number is <>;

   with function "+"(A : in Number) return Number is <>;
   with function "-"(A : in Number) return Number is <>;

   with function "+"(A, B : in Number) return Number is <>;
   with function "-"(A, B : in Number) return Number is <>;
   with function "*"(A, B : in Number) return Number is <>;
   with function "/"(A, B : in Number) return Number is <>;

   with function ">"(A, B : in Number) return Boolean is <>;
   with function "<"(A, B : in Number) return Boolean is <>;
   with function ">="(A, B : in Number) return Boolean is <>;
   with function "<="(A, B : in Number) return Boolean is <>;
   with function "="(A, B : in Number) return Boolean is <>;

package Vectors is

   ----------
   -- Vectors
   ----------

   -- A two-dimensional vector.
   type Vector is record
      X, Y : Number;
   end record;

   --------------------
   -- Vector operations
   --------------------

   -- Unary operators.
   function "+"(A : in Vector) return Vector;
   function "-"(A : in Vector) return Vector;

   -- Addition and substraction.
   function "+"(A, B : in Vector) return Vector;
   function "-"(A, B : in Vector) return Vector;

   -- Multiplication for corresponding components.
   function "*"(A, B : in Vector) return Vector;

   -- Operations with scalars.
   function "*"(A : in Vector; B : in Number) return Vector;
   function "*"(A : in Number; B : in Vector) return Vector;
   function "/"(A : in Vector; B : in Number) return Vector;
   function "abs"(A : in Vector) return Number;

   -- Mirroring.
   function Mirror_Y(A : in Vector) return Vector;

   -- Convert a vector to a string.
   function To_String
     (A : in Vector-- Convert this vector.
     return String;  -- The string representation.

   -- Convert a vector to a string, with explicit tolerance.
   function To_String
     (A         : in Vector-- Convert this vector.
      Tolerance : in Number-- Tolerance level.
     return String;          -- The string representation.

   -------------
   -- Rectangles
   -------------

   -- A rectangle, specified by coordinates of top left and bottom
   -- right corner. X values increase from left to right, Y values
   -- increase from top to bottom.
   type Rectangle is record
      Left   : Number-- Minimum value of horizontal coordinates.
      Top    : Number-- Minimum value of vertical coordinates.
      Right  : Number-- Maximum value of horizontal coordinates.
      Bottom : Number-- Maximum value of vertical coordinates.
   end record;

   -------------------------
   -- Rectangle calculations
   -------------------------

   -- Calculate a bounding box.
   function Max
     (A, B : in Rectangle)
     return Rectangle;

   function "+"
     (A : in Rectangle;
      B : in Vector)
     return Rectangle;

   ------------------
   -- Rectangle sizes
   ------------------

   -- Calculate the width of the rectangle.
   function Get_Width
     (This : in Rectangle-- Calculate width of this rectangle.
     return Number;        -- Difference between right and left.

   -- Calculate the height of the rectangle.
   function Get_Height
     (This : in Rectangle-- Calculate height of this rectangle.
     return Number;        -- Difference between top and bottom.

   ------------------------
   -- Rectangle coordinates
   ------------------------

   -- Get the bottom left corner.
   function Get_Bottom_Left
     (This : in Rectangle-- Get corner from this rectangle.
     return Vector;        -- A vector containing left and bottom.

   -- Get the top right corner.
   function Get_Top_Right
     (This : in Rectangle-- Get corner from this rectangle.
     return Vector;        -- A vector containing right and top.

   -- Get the bottom left corner.
   function Get_Bottom_Right
     (This : in Rectangle-- Get corner from this rectangle.
     return Vector;        -- A vector containing right and bottom.

   -- Get the top right corner.
   function Get_Top_Left
     (This : in Rectangle-- Get corner from this rectangle.
     return Vector;        -- A vector containing left and top.

   --------------------
   -- String conversion
   --------------------

   -- Convert a rectangle to a string, with explicit tolerance.
   function To_String
     (This : in Rectangle-- Convert this rectangle.
     return String;        -- The string representation.

   -- Convert a rectangle to a string, with explicit tolerance.
   function To_String
     (This      : in Rectangle-- Convert this rectangle.
      Tolerance : in Number)    -- Tolerance level.
     return String;             -- The string representation.

end Vectors;