哪位老兄知道如何判断矩形与椭圆是否有交集(共250分)(150分)

  • 主题发起人 主题发起人 vvyang
  • 开始时间 开始时间
V

vvyang

Unregistered / Unconfirmed
GUEST, unregistred user!
我仅仅知道用 Intersect 能判断矩形与矩形是否有交集。
哪位大虾知道如何用 API 判断矩形与椭圆是否有交集,用数学方法判断我还是会的。
这还有100分,不成敬意:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3343910
 
我还想知道圆和圆的交集怎么求?
 
哪有这样的API 啊
 
用RectInRegion判断看看
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
btn1: TBitBtn;
procedure FormPaint(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
RGN: HRGN;
Rect: TRect;
implementation

{$R *.dfm}

procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Rectangle(10, 10, 100, 100);
Canvas.Ellipse(50, 50, 150, 150);
end;

procedure TForm1.btn1Click(Sender: TObject);
begin
if RectInRegion(RGN, rect) then
ShowMessage('in');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
RGN := CreateEllipticRgn(50, 50, 150, 150);
SetRect(Rect, 10, 10, 100, 100);
end;

end.
 
CombineRgn(
p1: HRGN; {a handle to the combined region}
p2: HRGN; {a handle to the first region}
p3: HRGN; {a handle to the second region}
p4: Integer {region combination flag}
): Integer; {returns the type of the combined region}

CombineRgn p4 values
Value Description
RGN_AND The resulting region is the intersection of the two specified regions.
RGN_COPY The resulting region is a copy of the region identified by the p2 parameter.
RGN_DIFF The resulting region is the area of the region identified by the p2 parameter that is not in the area of the region identified by the p3 parameter.
Region and Path Functions The combined region used as a clipping region
RGN_OR The resulting region is the union of the two specified regions.
RGN_XOR The resulting region is the union of the two specified regions excluding any overlapping areas.


CombineRgn return values
Value Description
NULLREGION Indicates an empty region.
SIMPLEREGION Indicates a single rectangular region.
COMPLEXREGION Indicates a region consisting of more than one rectangle.
ERROR Indicates an error occurred and no region was created.
 
终结者
CombineRgn(rgnDest, rgn1, rgn2, RGN_AND);
然后判断rgnDest是否空:)
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

╰=========================================╯
 
kaoleoloi,我真的真的很烦你了。
 
同意 hwljerry, 需要转换为 Region 判断
 
谢谢各位,我仅仅判断是否有交集,用 RectInRegion 就行了。
请 hwljerry、VictorWoo、wk_knife 到这里再领 300 分:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3340415
 
后退
顶部