续集 :
while Degree<PI DO //角度递增旋转
Begin
PloyRotate(RandomPoly,TempPoly,Degree); //变换
ARect:=BuildMinRect(TempPoly); //求水平包含矩形
IF Arect.Size<SizeMin then
Begin
SizeMin:=ARect.Size; //记录最小面积的包含矩形
Minrect:=ARect;
MinRect.Degree:=Degree;
End;
Degree:=Degree+Step;
End;
SetLength(TempPoly,4);
TempPoly[0]:=MinRect.p1; TempPoly[1]:=MinRect.p2;
TempPoly[2]:=MinRect.p3; TempPoly[3]:=MinRect.p4;
PloyRotate(TempPoly,RectPoly,-Minrect.Degree); //反向变换结果矩形
Canvas.Brush.Color:=Clwhite;
Canvas.Rectangle(Canvas.Cliprect); //清除原内容
Canvas.Pen.Color:=ClBlue; //画多边形
canvas.Moveto(Round(RandomPoly[0].X),Round(RandomPoly[0].Y));
For I:=1 to J-1 do
canvas.Lineto(Round(RandomPoly.X),Round(RandomPoly.Y));
canvas.Lineto(Round(RandomPoly[0].X),Round(RandomPoly[0].Y));
Canvas.Pen.Color:=ClRed; //画包含矩形
canvas.Moveto(Round(RectPoly[0].X),Round(RectPoly[0].Y));
For I:=1 to 3 do
canvas.Lineto(Round(RectPoly.X),Round(RectPoly.Y));
canvas.Lineto(Round(RectPoly[0].X),Round(RectPoly[0].Y));
End;
end.