Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > rectangle contains point

Reply
Thread Tools

rectangle contains point

 
 
bob smith
Guest
Posts: n/a
 
      10-05-2012
So, I have a rectangle class as follows:

public class My_Rectangle {
double x, y, width, height;
AffineTransform aft;

Anyone know a good strategy for checking if a point is in the rectangle?

The main difficulty is the transform.
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      10-05-2012
On 10/5/2012 12:00 PM, bob smith wrote:
> So, I have a rectangle class as follows:
>
> public class My_Rectangle {
> double x, y, width, height;
> AffineTransform aft;
>
> Anyone know a good strategy for checking if a point is in the rectangle?
>
> The main difficulty is the transform.



http://lmgtfy.com/?q=computational+geometery

Seriously, it's a big subject. I don't have any easy answers.



 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      10-05-2012
On 10/5/2012 3:00 PM, bob smith wrote:
> So, I have a rectangle class as follows:
>
> public class My_Rectangle {
> double x, y, width, height;
> AffineTransform aft;
>
> Anyone know a good strategy for checking if a point is in the rectangle?
>
> The main difficulty is the transform.


I'll assume that x/y/width/height represent an untransformed
rectangle, and that you want to test whether the point is inside
the quadrilateral formed by transforming the rectangle with aft.
If that's the question, I see two approaches:

- Transform the rectangle and represent the result as a
Polygon, then use Polygon's contains() method.

- Inverse-transform the point and test whether the transformed
point is inside the original rectangle.

If that's not the question, please explain more fully.

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d
 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      10-05-2012
On 10/05/2012 03:00 PM, bob smith wrote:
> So, I have a rectangle class as follows:
>
> public class My_Rectangle {
> double x, y, width, height;
> AffineTransform aft;
>
> Anyone know a good strategy for checking if a point is in the rectangle?
>
> The main difficulty is the transform.

John B. Matthews provided a strategy for this
in a reply to another of your recent posts.
 
Reply With Quote
 
bob smith
Guest
Posts: n/a
 
      10-05-2012
On Friday, October 5, 2012 2:23:18 PM UTC-5, Eric Sosman wrote:
> On 10/5/2012 3:00 PM, bob smith wrote:
>
> > So, I have a rectangle class as follows:

>
> >

>
> > public class My_Rectangle {

>
> > double x, y, width, height;

>
> > AffineTransform aft;

>
> >

>
> > Anyone know a good strategy for checking if a point is in the rectangle?

>
> >

>
> > The main difficulty is the transform.

>
>
>
> I'll assume that x/y/width/height represent an untransformed
>
> rectangle, and that you want to test whether the point is inside
>
> the quadrilateral formed by transforming the rectangle with aft.
>
> If that's the question, I see two approaches:
>
>
>
> - Transform the rectangle and represent the result as a
>
> Polygon, then use Polygon's contains() method.
>
>
>
> - Inverse-transform the point and test whether the transformed
>
> point is inside the original rectangle.
>
>
>
> If that's not the question, please explain more fully.
>
>
>
> --
>
> Eric Sosman
>
> (E-Mail Removed)d


Excellent ideas. I went with inverse transform, and it works.

Thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Scenario 5: IS-IS routing on Frame Relay Multi-point and Point-to-Point David Sudjiman Cisco 0 06-08-2006 09:11 AM
Regex problem, match if line contains <a>, unless it also contains <b> James Dyer Perl 5 02-20-2004 12:29 PM
Rectangle object in asp.net? Kenneth ASP .Net 1 01-15-2004 08:53 AM
Check fileage with -M when path contains a point? Math55 Perl Misc 4 07-14-2003 01:10 AM



Advertisments