Changeset 74 for trunk/Packages/Common/Geometric.pas
- Timestamp:
- Mar 26, 2024, 10:57:56 PM (8 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Geometric.pas
r73 r74 1 unit UGeometric;1 unit Geometric; 2 2 3 3 interface … … 14 14 Position: TPoint; 15 15 Direction: TPoint; 16 function GetLength: Integer;16 function GetLength: Double; 17 17 function GetAngle: Double; 18 procedure SetLength(Value: Double); 19 class function Create(P1, P2: TPoint): TVector; static; 18 20 end; 19 21 … … 176 178 { TVector } 177 179 178 function TVector.GetLength: Integer;179 begin 180 Result := Trunc(Sqrt(Sqr(Direction.X) + Sqr(Direction.Y)));180 function TVector.GetLength: Double; 181 begin 182 Result := Sqrt(Sqr(Direction.X) + Sqr(Direction.Y)); 181 183 end; 182 184 … … 186 188 end; 187 189 190 procedure TVector.SetLength(Value: Double); 191 var 192 Angle: Double; 193 begin 194 Angle := GetAngle; 195 Direction := Point(Round(Cos(Angle) * Value), 196 Round(Sin(Angle) * Value)); 197 end; 198 199 class function TVector.Create(P1, P2: TPoint): TVector; 200 begin 201 Result.Position := P1; 202 Result.Direction := Point(P2.X - P1.X, P2.Y - P1.Y); 203 end; 204 188 205 end. 189
Note:
See TracChangeset
for help on using the changeset viewer.