How to define a persistent record containing other constant records in Delphi? Case study: a matrix using vectors

Let's say I have a simple entry in a block, for example:

TVector2D = record
public
  class function New(const x, y: Accuracy): TVector2D; static;
public
  x, y: Accuracy;
end;

Then I have a second record in the same block, which is built using a set of the above records, for example:

TMatrix3D = record
public
  class function New(const row1, row2, row3: TVector3D): TMatrix3D; static;
public
  Index : array [0..2] of TVector3D;
end;

Then I define the axis direction constants as follows:

//Unit vector constants
const
  iHat : TVector3D = (x: 1; y: 0; z: 0);
  jHat : TVector3D = (x: 0; y: 1; z: 0);
  kHat : TVector3D = (x: 0; y: 0; z: 1);

Now I want to define another constant using the constants above, for example:

  identity : TMatrix3D = (row1: iHat; row2: jHat; row3: kHat);

However, this attempt does not work. How can I do this in Delphi XE2?

Thank you very much for your efforts. :-)

+4
source share
1 answer

. . , .

: :

, - fieldName: , , - . .

, :

const
  identity: TMatrix3D = (Index:
    ((x: 1; y: 0; z: 0),
     (x: 0; y: 1; z: 0),
     (x: 0; y: 0; z: 1))
    );

, , , , .

+11

All Articles