Ignore:
Timestamp:
May 17, 2023, 12:18:41 AM (12 months ago)
Author:
chronos
Message:
  • Modified: Draw curved metro lines.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UGeometric.pas

    r105 r140  
    1414    Position: TPoint;
    1515    Direction: TPoint;
    16     function GetLength: Integer;
     16    function GetLength: Double;
    1717    function GetAngle: Double;
     18    procedure SetLength(Value: Double);
     19    class function Create(P1, P2: TPoint): TVector; static;
    1820  end;
    1921
     
    176178{ TVector }
    177179
    178 function TVector.GetLength: Integer;
    179 begin
    180   Result := Trunc(Sqrt(Sqr(Direction.X) + Sqr(Direction.Y)));
     180function TVector.GetLength: Double;
     181begin
     182  Result := Sqrt(Sqr(Direction.X) + Sqr(Direction.Y));
    181183end;
    182184
     
    186188end;
    187189
     190procedure TVector.SetLength(Value: Double);
     191var
     192  Angle: Double;
     193begin
     194  Angle := GetAngle;
     195  Direction := Point(Round(Cos(Angle) * Value),
     196    Round(Sin(Angle) * Value));
     197end;
     198
     199class function TVector.Create(P1, P2: TPoint): TVector;
     200begin
     201  Result.Position := P1;
     202  Result.Direction := Point(P2.X - P1.X, P2.Y - P1.Y);
     203end;
     204
    188205end.
    189206
Note: See TracChangeset for help on using the changeset viewer.