Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

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

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

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

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))^2
A= ---------------------------------
         (x2-x1)^2+(y2-y1)^2
if A above W*W then point(x,y) don`t hit to rectangle
else 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)^2

So if (B>=0)and(B<=1)and(A<=W*W) then given point
hit to rectangle.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close