Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19143

Re: rectangle contains point

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: rectangle contains point
Date 2012-10-05 15:23 -0400
Organization A noiseless patient Spider
Message-ID <k4nc36$n46$1@dont-email.me> (permalink)
References <ae6e3b64-41bf-40c9-9197-1097c164033b@googlegroups.com>

Show all headers | View raw


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
esosman@comcast-dot-net.invalid

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

rectangle contains point bob smith <bob@coolfone.comze.com> - 2012-10-05 12:00 -0700
  Re: rectangle contains point markspace <-@.> - 2012-10-05 12:20 -0700
  Re: rectangle contains point Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-05 15:23 -0400
    Re: rectangle contains point bob smith <bob@coolfone.comze.com> - 2012-10-05 14:16 -0700
  Re: rectangle contains point Jeff Higgins <jeff@invalid.invalid> - 2012-10-05 15:43 -0400

csiph-web