Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19148
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2012-10-05 14:16 -0700 |
| References | <ae6e3b64-41bf-40c9-9197-1097c164033b@googlegroups.com> <k4nc36$n46$1@dont-email.me> |
| Message-ID | <f4f3eda8-4c48-4ab3-b777-5dc5d2e5940b@googlegroups.com> (permalink) |
| Subject | Re: rectangle contains point |
| From | bob smith <bob@coolfone.comze.com> |
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
>
> esosman@comcast-dot-net.invalid
Excellent ideas. I went with inverse transform, and it works.
Thanks.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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