home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1987 / 07 / grafik / transmat.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-05-04  |  1.9 KB  |  57 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                              GRAFMAT.PAS                                *)
  3. (*        Grafikserie: Routinen zur Matrizen-/Vektor-Handhabung            *)
  4. (* Setzen die Konstanten xMatDim (Matrizen-x- bzw. Vektor-Ausdehnung),     *)
  5. (* yMatDim (Matrizen-y-Ausdehnung) und die TYPEn tVektor und tMatrix       *)
  6. (* voraus.                                                                 *)
  7. (*-------------------------------------------------------------------------*)
  8.  
  9. PROCEDURE Einheitsmatrix (VAR Matrix: tMatrix);
  10.  
  11. VAR Zeile, Spalte: INTEGER;
  12.  
  13. BEGIN
  14.   FOR Zeile := 1 TO yMatDim DO
  15.     FOR Spalte := 1 TO xMatDim DO
  16.       Matrix[Zeile,Spalte] := Ord(Zeile = Spalte)
  17. END;
  18.  
  19. (*-------------------------------------------------------------------------*)
  20. (*  Multiplikation zweier gleich dimensionierter (quadratischer) Matrizen: *)
  21.  
  22. PROCEDURE MatMult(a, b: tMatrix; VAR Res: tMatrix);
  23.  
  24. VAR Zeile, Spalte, i: INTEGER;
  25.     Sum: REAL;
  26.  
  27. BEGIN
  28.   FOR Zeile := 1 TO yMatDim DO
  29.     FOR Spalte := 1 TO xMatDim DO
  30.     BEGIN
  31.       Sum := 0;
  32.       FOR i := 1 TO yMatDim DO
  33.         Sum := Sum + a[Zeile,i] * b[i,Spalte];
  34.       Res[Zeile,Spalte] := Sum
  35.     END
  36. END;
  37.  
  38. (*-------------------------------------------------------------------------*)
  39. (* Wendet die Transformationsmatrix "TransMat" auf den Vektor "Vektor" an: *)
  40.  
  41. PROCEDURE VektorTrans(VAR Vektor: tVektor; TransMat: tMatrix);
  42.  
  43. VAR Spalte, Zeile: INTEGER;
  44.     Temp: tVektor;
  45.  
  46. BEGIN
  47.   Temp := Vektor;
  48.   FOR Spalte := 1 TO xMatDim DO BEGIN
  49.     Vektor[Spalte] := 0;
  50.     FOR Zeile := 1 TO yMatDim DO
  51.       Vektor[Spalte] := Vektor[Spalte] + Temp[Zeile] * TransMat[Zeile,Spalte]
  52.   END
  53. END;
  54.  
  55. (*-------------------------------------------------------------------------*)
  56. (*                             Ende GRAFMAT.PAS                            *)
  57.