File : test_rotation_matrices.adb


------------------------------------------------------------------------------
--
--  procedure Test_Rotation_Matrices (body)
--
--  Intended to test package Rotation_Matrices.
--
------------------------------------------------------------------------------
--  Update information:
--
--  1998.03.23-24 (Jacob Sparre Andersen)
--    Written.
--
--  (Insert additional update information above this line.)
------------------------------------------------------------------------------

with Ada.Float_Text_IO;
with Ada.Text_IO;

with Float_3D_Vectors;
with Float_Angles;
with Rotation_Matrices;

procedure Test_Rotation_Matrices is

   ---------------------------------------------------------------------------

   use Ada.Float_Text_IO;
   use Ada.Text_IO;

   use Float_3D_Vectors;
   use Float_Angles;
   use Rotation_Matrices;

   type Hjørner is new Integer range 0 .. 7;

   type Terning_Type is array (Hjørner) of Point;

   type Forbindelse_Type is
      record
         Fra, Til : Hjørner;
      end record;

   Forbindelser : constant array (1 .. 10) of Forbindelse_Type
                    := ((Fra => 0, Til => 1), (Fra => 0, Til => 2),
                        (Fra => 0, Til => 4), (Fra => 1, Til => 3),
                        (Fra => 1, Til => 5), (Fra => 2, Til => 3),
                        (Fra => 2, Til => 6), (Fra => 3, Til => 7),
                        (Fra => 4, Til => 6), (Fra => 5, Til => 7));

   ---------------------------------------------------------------------------
   --  procedure Line:

   procedure Line (From, To : in     Point) is

   begin --  Line
      Put (From (1));
      Put (" ");
      Put (From (2));
      Put (" moveto ");
      Put (To (1));
      Put (" ");
      Put (To (2));
      Put_Line (" lineto stroke");
   end Line;

   ---------------------------------------------------------------------------
   --  procedure Tegn:

   procedure Tegn (Terning : in     Terning_Type) is

   begin --  Tegn
      Put ("1 0 0 setrgbcolor ");
      Line (Terning (0), Terning (1));
      Put ("0 1 0 setrgbcolor ");
      Line (Terning (0), Terning (2));
      Put ("0 0 1 setrgbcolor ");
      Line (Terning (0), Terning (4));

      Put_Line (" 0.5 0.5 0.5 setrgbcolor");

      for Indeks in Forbindelser'First + 3 .. Forbindelser'Last loop
         Line (Terning (Forbindelser (Indeks).Fra),
               Terning (Forbindelser (Indeks).Til));
      end loop;
   end Tegn;

   ---------------------------------------------------------------------------

   Terning : constant Terning_Type
               := ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0),
                   (0.0, 0.5, 0.0), (1.0, 0.5, 0.0),
                   (0.0, 0.0, 0.3), (1.0, 0.0, 0.3),
                   (0.0, 0.5, 0.3), (1.0, 0.5, 0.3));
   Drej    : constant Matrix_Type
               := Rotation_Around_X (Angle_In_Degrees (-6.0))
                    * Rotation_Around_Z (Angle_In_Degrees (3.0));

   En_Grad : constant Angle := Angle_In_Degrees (1.0);

   Drejet : Terning_Type := Terning;

begin --  Test_Rotation_Matrices
   Put_Line ("%!");
   Put_Line ("50 50 scale");
   Put_Line ("1.5 1.5 translate 0.02 setlinewidth");

   for Index in 0 .. 10 loop
      declare
         Rotation : constant Matrix_Type :=
                      Rotation_Around_X (Float (- 6 * Index) * En_Grad) *
                        Rotation_Around_Z (Float (3 * Index) * En_Grad);
      begin
         for Hjørne in Drejet'Range loop
            Drejet (Hjørne) := Rotation * Terning (Hjørne);
         end loop;

         Tegn (Drejet);
      end;

      --  for Corner in Drejet'Range loop
      --     Drejet (Corner) := Drej * Drejet (Corner);
      --  end loop;

      Put_Line ("0.0 1.0 translate");
   end loop;
end Test_Rotation_Matrices;