Smart questions
Smart people
 Find A ForumFind An Expert
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Remember Me

Are you a
Computer / IT professional?
Join Tek-Tips now!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Just copy and paste the

Feedback

"...One of the best run forums I have used in years! ...I like the way the site is organized and your no tolerance of flames..."

Geography

Where in the world do Tek-Tips members come from?

help detecting clicks on the line i have drawn

 Forum Search FAQs Links Jobs Whitepapers MVPs
 mike9606 (Programmer) 25 May 00 21:33
 I need to be able to detect or work out if the line has been clicked, i have an array of tpoint and am able to detect if clicks occured on the skelton path of the line, however i'm unsure as to how to work out if the click occured between two tpoints on the line, ie i have point a and point b and a line is drawn between them how do i work out if there has been a click on the line drawn between a and b? and can i create a method so that the click will be automatically detected and methods called to determine if the click was on the line?
 VladimirA (Programmer) 26 May 00 8:56
 Hi! You can identify if click point lie in the rectangle if do this:    ------------------------------    ¦                            ¦ P1 *                            * P2    ¦                            ¦    ------------------------------P1 and P2 - two points of line (P1=(x1,y1);P2=(x2,y2))W - half width of this line;no matter how this rectangle oriented on plane,if You have point (x,y) then You can calculate    ((x-x1)*(y2-y1)-(x2-x1)*(y-y1))^2A= ---------------------------------         (x2-x1)^2+(y2-y1)^2if A above W*W then point(x,y) don`t hit to rectangleelse point(x,y) lie in given rectangle.
 VladimirA (Programmer) 26 May 00 10:36
 Ups! :)I missed second condition.   (x-x1)*(x2-x1)+(y-y1)*(y2-y1)B= -----------------------------       (x2-x1)^2+(y2-y1)^2So if (B>=0)and(B<=1)and(A<=W*W) then given pointhit to rectangle.

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!