all groups > dotnet performance > february 2006 >
You're in the

dotnet performance

group:

Rectangle Intersect problem


Rectangle Intersect problem Xafier
2/16/2006 6:25:43 AM
dotnet performance:
Hi

I'm working on a custom control thats pretty graphics intensive, it can
at an extreme with current test data, have upto 60,000 lines (each with
upto around 4 or 5 points).

To improve speed I'm using a pretty slow checking procedure that tests
the start and end points and whether the line intersects the box I'm
giving it as my screen.

The problem is, is that its slow... and so far I'm unable to find a
built in procedure for this or any fast code anywhere to solve the
problem.

Surely the Rectangle.IntersectsWith() procedure uses line intersect
algorithm... but I can't figure how to get access to it... which I
probably can't...

so, any suggestions or advice?

GDI+ seems to be dirt slow at drawing thousands of lines, I'm trying to
optimize things as much as I can as when I originally wrote this I was
new to C#, but 6 months later I have made quite a few optimizations but
it's still terribly slow when I "zoom out" and need to render a lot
more lines with scaling.

Thanks
RE: Rectangle Intersect problem AMercer
2/17/2006 8:30:04 AM
[quoted text, click to view]

Maybe you could speed things up as follows. You have a rectangle for the
screen box. For each line, make a new rectangle with the line on one or the
other diagonal. Now use Rectangle.IntersectsWith on these two rectangles.
If false, you do not have an intersection, and if true you might, so run your
slow routine. If both (1) IntersectsWith is fast and (2) you have enough
lines that return false, you should speed things up. I haven't tried it, no
AddThis Social Bookmark Button