Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Microsoft .Net
 Real-Time Graphics Tools for .Net (VB and C#)
 How to detect if a given point is inside an object

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
soundar Posted - 07 Aug 2008 : 18:19:26
I have a list of RTRoundedRectangle2D objects.

I want to find out if a given point, in PHYS_COORDS, is inside any of these RTRoundedRectangle2D objects by iterating through them like so:

for each rt in myRectangles
if rt...Contains(x,y) then
'show the rectangle
else
'hide the rectangle
end if
next

myRectangles is a global List Of(RTRoundedRectangle2D)
I can show and hide the rectangles by adding the containing rectangle to the ChartView object, and by removing the previous object.

I cannot figure out how to do the hit test for a given point. This is a point known to me (not a mouse click point) and I am not sure if I should use the NearestDataPoint methods.

Please help.
3   L A T E S T    R E P L I E S    (Newest First)
quinncurtis Posted - 07 Aug 2008 : 22:14:38
Those routines work in device (pixel) coordinates since they are designed to process mouse clicks.
soundar Posted - 07 Aug 2008 : 20:26:57
Thanks. I guess I was looking for a one-line function...because I noticed the CheckIntersection function and also the Contains method of the Rectangle2D class. I thought I should be able to use them.
quinncurtis Posted - 07 Aug 2008 : 18:54:03
If you restrict the test point and rectangle to physical coordinates it seems pretty simple to us. Perhaps we are missing something. This does not take into account the rounded corners, but none of our routines will.

public bool HitTest (Point2D pt, RTRoundedRectangle2D rect)
{
   bool result = false;
   if ((pt.X > rect.X) &&
       (pt.Y > rect.Y) &&
       (pt.X < (rect.X + rect.Width)) &&
       (pt.Y < (rect.Y + rect.Height)))
       {
          result = true;
       }
     return result;
}

Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07