Changeset 25 for trunk/UGeometric.pas
- Timestamp:
- Apr 12, 2015, 12:08:05 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGeometric.pas
r13 r25 13 13 function Distance(P1, P2: TPoint): Integer; 14 14 function Dot(const P1, P2: TPoint): Double; 15 function AddPoint(const P1, P2: TPoint): TPoint; 15 16 function SubPoint(const P1, P2: TPoint): TPoint; 16 17 function PointToLineDistance(const P, V, W: TPoint): Integer; … … 18 19 function RotatePoint(Center, P: TPoint; Angle: Double): TPoint; 19 20 function RotatePoints(Center: TPoint; P: TPointArray; Angle: Double): TPointArray; 21 function LineIntersect(LineAP1, LineAP2, LineBP1, LineBP2: TPoint): TPoint; 22 function ArcTan2Point(Point: TPoint): Float; 23 function ArcTanPoint(Point: TPoint): Float; 20 24 21 25 implementation … … 29 33 begin 30 34 Result := P1.X * P2.X + P1.Y * P2.Y; 35 end; 36 37 function AddPoint(const P1, P2: TPoint): TPoint; 38 begin 39 Result.X := P1.X + P2.X; 40 Result.Y := P1.Y + P2.Y; 31 41 end; 32 42 … … 88 98 end; 89 99 100 function LineIntersect(LineAP1, LineAP2, LineBP1, LineBP2: TPoint): TPoint; 101 Var 102 LDetLineA, LDetLineB, LDetDivInv: Double; 103 LDiffLA, LDiffLB: TPoint; 104 begin 105 LDetLineA := LineAP1.X * LineAP2.Y - LineAP1.Y * LineAP2.X; 106 LDetLineB := LineBP1.X * LineBP2.Y - LineBP1.Y * LineBP2.X; 107 108 LDiffLA := SubPoint(LineAP1, LineAP2); 109 LDiffLB := SubPoint(LineBP1, LineBP2); 110 111 LDetDivInv := 1 / ((LDiffLA.X * LDiffLB.Y) - (LDiffLA.Y * LDiffLB.X)); 112 113 Result.X := Trunc(((LDetLineA * LDiffLB.X) - (LDiffLA.X * LDetLineB)) * LDetDivInv); 114 Result.Y := Trunc(((LDetLineA * LDiffLB.Y) - (LDiffLA.Y * LDetLineB)) * LDetDivInv); 115 end; 116 117 function ArcTan2Point(Point: TPoint): Float; 118 begin 119 Result := ArcTan2(Point.Y, Point.X); 120 end; 121 122 function ArcTanPoint(Point: TPoint): Float; 123 begin 124 Result := ArcTan(Point.Y / Point.X); 125 end; 90 126 91 127 end.
Note:
See TracChangeset
for help on using the changeset viewer.