Skip to content

Commit

Permalink
Rotation of coordinates has been implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvmorozov committed Sep 26, 2019
1 parent 5359c38 commit f9f3070
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 6 deletions.
32 changes: 29 additions & 3 deletions ExamplesMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface
SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons,
Contnrs,
{$ENDIF}
Algorithm, DownhillSimplexAlgorithm, SimpMath;
Algorithm, DownhillSimplexAlgorithm, SimpMath, Math3d;

type
{ TForm1 }
Expand All @@ -33,6 +33,7 @@ TForm1 = class(TForm)

procedure GenerateRandomPointCloud;
procedure InitializeVariableParameters;
procedure TransformPointCloudCoordinates;

function ComputeCenterOfMass: TDoubleVector3;
{ Retuns triplet of max coordinates (actually not a vector). }
Expand Down Expand Up @@ -169,9 +170,34 @@ function TForm1.ComputeMinCoordinates: TDoubleVector3;
end;
end;

{$hints off}
procedure TForm1.TransformPointCloudCoordinates;
var RotX, RotY, RotZ, RotMatr: TMatrix;
i: LongInt;
Point: T3DVector;
Vector: T3Vector;
begin
{ Computing matrices. }
GetMatrixRotX(Alpha, RotX);
GetMatrixRotY(Beta, RotY);
GetMatrixRotZ(Gamma, RotZ);
{ Computes rotation matrix. }
Mul3DMatrix(RotY, RotZ, RotMatr);
Mul3DMatrix(RotX, RotMatr, RotMatr);

for i := 0 to PointCloud.Count - 1 do
begin
Point := T3DVector(PointCloud[i]);
Vector := Point.Vector;
MulVectMatr(RotMatr, Vector);
Point.Vector := Vector;
end;
end;
{$hints on}

function TForm1.ComputeBoxVolume: Double;
var A, B, C: Double; // Sizes of the box.
MaxCoords, MinCoords: TDoubleVector3;
var MaxCoords, MinCoords: TDoubleVector3;
A, B, C: Double; // Sizes of the box.
begin
{ Computes volume of bounding box. }
MaxCoords := ComputeMaxCoordinates;
Expand Down
Loading

0 comments on commit f9f3070

Please sign in to comment.