|
-- This program fills an array with three points with random coordinates
|
|
-- and then calculates the distances between them.
|
|
|
|
WITH Ada.Float_Text_Io;
|
|
WITH Ada.Integer_Text_Io;
|
|
WITH Ada.Text_Io;
|
|
WITH Ada.Numerics.Float_Random;
|
|
WITH Geometry;
|
|
USE Geometry;
|
|
|
|
PROCEDURE Getline IS
|
|
|
|
Index : Geometry.INDEXTYPE := 0;
|
|
Seed : Ada.Numerics.Float_Random.GENERATOR;
|
|
|
|
TYPE Triangle IS ARRAY (Geometry.INDEXTYPE'Range) OF Geometry.POINT;
|
|
Tri : TRIANGLE;
|
|
|
|
BEGIN
|
|
Ada.Numerics.Float_Random.Reset (Seed);
|
|
|
|
FOR I IN Geometry.INDEXTYPE'Range LOOP
|
|
Tri (I) :=
|
|
(X => Ada.Numerics.Float_Random.Random (Seed) * 10.0,
|
|
Y => Ada.Numerics.Float_Random.Random (Seed) * 10.0,
|
|
Index => INTEGER (I));
|
|
END LOOP;
|
|
|
|
FOR I IN Geometry.INDEXTYPE'Range LOOP
|
|
Geometry.Put (Tri (I));
|
|
Geometry.Put (Tri (I + 1));
|
|
Ada.Text_Io.Put ("Distance between points");
|
|
Ada.Integer_Text_Io.Put (Tri (I).Index, Width => 2);
|
|
Ada.Text_Io.Put (" and ");
|
|
Ada.Integer_Text_Io.Put (Tri (I + 1).Index, Width => 2);
|
|
Ada.Text_Io.Put (" is ");
|
|
Ada.Float_Text_Io.Put
|
|
(Geometry.Get_Distance (Tri (I + 1), Tri (I)), Aft => 4, Exp => 0);
|
|
Ada.Text_Io.New_Line (2);
|
|
END LOOP;
|
|
END Getline;
|