# how to know a point lies inside a rectangle or not?

Page 1 of 1

## 2 Replies - 1033 Views - Last Post: 28 November 2013 - 11:55 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=335234&amp;s=fdbf0f80863f60ffdbb1b68ac099f01a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 marklr

Reputation: 0
• Posts: 12
• Joined: 21-July 13

# how to know a point lies inside a rectangle or not?

Posted 28 November 2013 - 11:02 PM

suppose i have a Point coordinates and a rectangle(or polygon),how to know whether a point lies inside a rectangle or not?
Is This A Good Question/Topic? 0

## Replies To: how to know a point lies inside a rectangle or not?

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11111
• Posts: 41,647
• Joined: 27-December 08

## Re: how to know a point lies inside a rectangle or not?

Posted 28 November 2013 - 11:24 PM

You check based on the boundary x and y points for the rectangle. If x_{0} <= x_{i} <= x_{n} and y_{0} <= y_{i} <= y_{n}, then your point (x_{i}, y_{i}) is in the rectangle.

### #3 Skydiver

• Code herder

Reputation: 3932
• Posts: 12,474
• Joined: 05-May 12

## Re: how to know a point lies inside a rectangle or not?

Posted 28 November 2013 - 11:55 PM

And if you are using the .NET Rectangle class, you can use the Contains() method: http://msdn.microsof...(v=vs.110).aspx