Changeset 140 for trunk/Packages/Common/UGeometric.pas
- Timestamp:
- May 17, 2023, 12:18:41 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UGeometric.pas
r105 r140 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 206
Note:
See TracChangeset
for help on using the changeset viewer.