Re: finding if point is inside irregular rectangle
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 25, 2002
- 434 views
Tone, What is the type & range of values for the points to test and of the corners of your quadrilateral? Are they non-integer, like when you were interested in finding if points were inside a normal rectangle? I ask because for integers within a certain range of values (video screen settings), there is a very easy way to tell if a candidate point is within a polygon of any shape at all. You just draw the polygon on a non-displayed screen, filled with some color other than background, and then test if the point in question is that color. It's probably not fast, but it's easy. Dan Moyer ----- Original Message ----- From: <tone.skoda at siol.net> To: "EUforum" <EUforum at topica.com> Sent: Monday, February 25, 2002 11:22 AM Subject: finding if point is inside irregular rectangle Here's another problem: I need to find out if point lies inside an irregular rectangle. Irregular rectangle has 4 corners but they don't need to be 90 degree, although they can still be. Example of irregular rectangle: Please view in a fixed-width font such as Courier. |-- | ---- | --- | ---- | --- | ---- | -\ | \\ | \ | \ | \\ | \ | \ | \\ |------ \ ----------- \ ---------- \\ ----------- \ -----\ Below is function which needs to be finished. I would do it myself but I'm not too good at math. -- bounds parameter should define 4 points of rectangle and should have these members: -- 1,2: left_top_x, left_top_y, -- 3,4: left_bottom_x, left_bottom_y, -- 5,6: right_top_x, right_top_y, -- 7,8: right_bottom_x, right_bottom_y. function is_point_in_irregular_rect (sequence point, sequence bounds) -- This is returned. integer is_point_in_rect -- TODO return is_point_in_rect end function