Index

Package: Math

Description

package GL.Math is

Packages

REF (new Ada.Numerics.Generic_Elementary_Functions)

package REF is new Ada.Numerics.Generic_Elementary_Functions (Double);

RIO (new Float_IO)

package RIO is new Ada.Text_IO.Float_IO                      (Double);

Types

Vector_4D

type Vector_4D is array (0 .. 3) of Double;

References:

gl-math.ads:43:8 (declaration)
gl-math.adb:115:62 (reference)
gl-math.adb:117:24 (reference)
gl-math.adb:118:15 (reference)
gl-math.adb:126:68 (reference)
gl-math.adb:128:43 (reference)
gl-math.ads:73:61 (reference)

Matrix

type Matrix    is array (Positive range <>, Positive range <>) of aliased Double;

References:

gl-math.ads:59:8 (declaration)
gl-math.adb:194:47 (reference)
gl-math.adb:196:64 (reference)
gl-math.adb:198:25 (reference)
gl-math.ads:60:25 (reference)
gl-math.ads:61:25 (reference)
gl-math.ads:107:46 (reference)
gl-math.ads:109:63 (reference)

Matrix_33

type Matrix_33 is new Matrix (1 .. 3, 1 .. 3);

References:

gl-math.ads:60:8 (declaration)
gl-math.adb:56:25 (reference)
gl-math.adb:56:43 (reference)
gl-math.adb:58:12 (reference)
gl-math.adb:61:16 (reference)
gl-math.adb:62:19 (reference)
gl-math.adb:66:25 (reference)
gl-math.adb:76:22 (reference)
gl-math.adb:81:16 (reference)
gl-math.adb:85:22 (reference)
gl-math.adb:86:43 (reference)
gl-math.adb:88:21 (reference)
gl-math.adb:134:28 (reference)
gl-math.adb:134:46 (reference)
gl-math.adb:143:22 (reference)
gl-math.adb:150:55 (reference)
gl-math.adb:152:20 (reference)
gl-math.adb:178:56 (reference)
gl-math.adb:180:59 (reference)
gl-math.adb:212:66 (reference)
gl-math.adb:225:44 (reference)
gl-math.adb:272:38 (reference)
gl-math.adb:275:16 (reference)
gl-math.adb:276:19 (reference)
gl-math.adb:287:33 (reference)
gl-math.ads:65:21 (reference)
gl-math.ads:69:24 (reference)
gl-math.ads:69:42 (reference)
gl-math.ads:71:21 (reference)
gl-math.ads:75:27 (reference)
gl-math.ads:75:45 (reference)
gl-math.ads:78:21 (reference)
gl-math.ads:80:54 (reference)
gl-math.ads:82:55 (reference)
gl-math.ads:87:58 (reference)
gl-math.ads:89:66 (reference)
gl-math.ads:93:43 (reference)
gl-math.ads:96:37 (reference)
gl-math.ads:99:32 (reference)

Matrix_44

type Matrix_44 is new Matrix (1 .. 4, 1 .. 4);

References:

gl-math.ads:61:8 (declaration)
gl-math.adb:94:22 (reference)
gl-math.adb:102:16 (reference)
gl-math.adb:106:22 (reference)
gl-math.adb:107:46 (reference)
gl-math.adb:109:21 (reference)
gl-math.adb:115:22 (reference)
gl-math.adb:121:16 (reference)
gl-math.adb:125:22 (reference)
gl-math.adb:126:46 (reference)
gl-math.adb:128:21 (reference)
gl-math.adb:138:28 (reference)
gl-math.adb:138:46 (reference)
gl-math.adb:268:8 (reference)
gl-math.ads:63:31 (reference)
gl-math.ads:72:21 (reference)
gl-math.ads:73:21 (reference)
gl-math.ads:76:27 (reference)
gl-math.ads:76:45 (reference)
type Matrix_44 is array (0 .. 3, 0 .. 3) of aliased Double; -- for GL.MultMatrix

Constants & Global variables

Id_33 (Matrix_33)

Id_33  : constant Matrix_33 := ((1.0, 0.0, 0.0),
                                (0.0, 1.0, 0.0),
                                (0.0, 0.0, 1.0));

References:

gl-math.ads:65:3 (declaration)

Subprograms & Entries

"-"

function "-" 
(a: Double_Vector_3D) return Double_Vector_3D;

References:

gl-math.ads:23:13 (declaration)
gl-math.adb:16:14 (body)

"*"

function "*" 
(a, b: Double_Vector_3D) return Double;

References:

gl-math.ads:29:13 (declaration)
gl-math.adb:20:14 (body)
gl-math.adb:39:53 (call)

Called by:

Angle defined at gl-math.ads:48:13

Norm2

function Norm2 
(a: Double_Vector_3D) return Double;

References:

gl-math.ads:38:12 (declaration)
gl-math.adb:28:13 (body)
gl-math.ads:39:18 (reference)

Angle

function Angle 
(Point_1, Point_2, Point_3: Double_Vector_3D) return Double;

References:

gl-math.ads:48:13 (declaration)
gl-math.adb:35:13 (body)
gl-math.adb:46:8 (label)

Calls:

* defined at gl-math.ads:29:13
- defined at gl-math.ads:26:13
Ada.Numerics.Generic_Elementary_Functions.Arccos defined at a-ngelfu.ads:108:13
Normalized defined at gl-math.ads:41:12
returns the angle between the vector Point_1 to Point_2 and the vector Point_3 to Point_2.

to_Degrees

function to_Degrees 
(Radians: Double) return Double;

References:

gl-math.ads:52:13 (declaration)
gl-math.adb:48:13 (body)

to_Radians

function to_Radians 
(Degrees: Double) return Double;

References:

gl-math.ads:53:13 (declaration)
gl-math.adb:50:13 (body)

"*"

function "*" 
(A, B: Matrix_33) return Matrix_33;

References:

gl-math.ads:69:13 (declaration)
gl-math.adb:56:14 (body)
gl-math.adb:74:9 (label)
gl-math.adb:174:17 (call)
gl-math.adb:174:22 (call)

"*"

function "*" 
(A: Matrix_44;
x: Double_Vector_3D) return Vector_4D;

References:

gl-math.ads:73:13 (declaration)
gl-math.adb:115:14 (body)
gl-math.adb:132:9 (label)

Transpose

function Transpose 
(A: Matrix_33) return Matrix_33;

References:

gl-math.ads:75:12 (declaration)
gl-math.adb:134:13 (body)

Transpose

function Transpose 
(A: Matrix_44) return Matrix_44;

References:

gl-math.ads:76:12 (declaration)
gl-math.adb:138:13 (body)

Det

function Det 
(A: Matrix_33) return Double;

References:

gl-math.ads:78:12 (declaration)
gl-math.adb:143:13 (body)

XYZ_rotation

function XYZ_rotation 
(ax, ay, az: Double) return Matrix_33;

References:

gl-math.ads:80:12 (declaration)
gl-math.adb:150:13 (body)
gl-math.adb:176:8 (label)
gl-math.adb:178:70 (call)

Calls:

* defined at gl-math.ads:69:13
Ada.Numerics.Generic_Elementary_Functions.Cos defined at a-ngelfu.ads:78:13
Ada.Numerics.Generic_Elementary_Functions.Sin defined at a-ngelfu.ads:68:13

XYZ_rotation

function XYZ_rotation 
(v: Double_Vector_3D) return Matrix_33;

References:

gl-math.ads:82:12 (declaration)
gl-math.adb:178:13 (body)

Look_at

function Look_at 
(direction: Double_Vector_3D) return Matrix_33;

References:

gl-math.ads:87:12 (declaration)
gl-math.adb:180:13 (body)
gl-math.adb:192:8 (label)

Calls:

* defined at gl-math.ads:32:13
Normalized defined at gl-math.ads:41:12
Gives a rotation matrix that corresponds to look into a certain direction. Camera swing rotation is arbitrary. Left - multiply by XYZ_Rotation (0.0, 0.0, az) to correct it.

Look_at

function Look_at 
(eye, center, up: Double_Vector_3D) return Matrix_33;

References:

gl-math.ads:89:13 (declaration)
gl-math.adb:212:13 (body)
gl-math.adb:222:8 (label)

Calls:

* defined at gl-math.ads:32:13
Normalized defined at gl-math.ads:41:12

Re_Orthonormalize

procedure Re_Orthonormalize 
(M: in out Matrix_33);

References:

gl-math.ads:93:13 (declaration)
gl-math.adb:225:14 (body)
gl-math.adb:263:8 (label)

Calls:

Ada.Numerics.Generic_Elementary_Functions.Sqrt defined at a-ngelfu.ads:42:13
This is for correcting cumulation of small computational errors, making the rotation matrix no more orthogonal

Multiply_GL_Matrix

procedure Multiply_GL_Matrix 
(A: Matrix_33);

References:

gl-math.ads:96:13 (declaration)
gl-math.adb:272:14 (body)
gl-math.adb:285:8 (label)
gl-math.adb:291:7 (call)

Called by:

Set_GL_Matrix defined at gl-math.ads:99:13

Calls:

GL.MultMatrixd defined at gl.ads:3288:14
Right - multiply current matrix by A

Set_GL_Matrix

procedure Set_GL_Matrix 
(A: Matrix_33);

References:

gl-math.ads:99:13 (declaration)
gl-math.adb:287:14 (body)
gl-math.adb:292:8 (label)
Impose A as current matrix

Almost_zero

function Almost_zero 
(x: Double) return Boolean;
For replacing the " = 0.0" test which is a Bad Thing

Almost_zero

function Almost_zero 
(x: GL.C_Float) return Boolean;

References:

gl-math.ads:104:12 (declaration)
gl-math.adb:309:13 (body)

Sub_Matrix

function Sub_Matrix 
(Self: Matrix;
start_Row, end_Row: Positive;
start_Col, end_Col: Positive) return Matrix;

References:

gl-math.ads:107:13 (declaration)
gl-math.adb:194:13 (body)
gl-math.adb:210:8 (label)