Click here to Skip to main content
15,907,910 members
Home / Discussions / C#
   

C#

 
GeneralMessageBox in Web Forms Pin
Imran Adam10-Dec-07 3:11
Imran Adam10-Dec-07 3:11 
GeneralRe: MessageBox in Web Forms Pin
Abhijit Jana10-Dec-07 3:49
professionalAbhijit Jana10-Dec-07 3:49 
GeneralRe: MessageBox in Web Forms Pin
Imran Adam10-Dec-07 9:54
Imran Adam10-Dec-07 9:54 
GeneralRe: MessageBox in Web Forms Pin
Abhijit Jana10-Dec-07 17:59
professionalAbhijit Jana10-Dec-07 17:59 
GeneralMath problem Pin
Mike Hankey10-Dec-07 2:38
mveMike Hankey10-Dec-07 2:38 
GeneralRe: Math problem Pin
Anthony Mushrow10-Dec-07 3:09
professionalAnthony Mushrow10-Dec-07 3:09 
GeneralRe: Math problem Pin
Mike Hankey10-Dec-07 3:55
mveMike Hankey10-Dec-07 3:55 
GeneralRe: Math problem Pin
Luc Pattyn10-Dec-07 3:26
sitebuilderLuc Pattyn10-Dec-07 3:26 
Hi Mike,

what you need is algebra, not geometry.

a straight line can be represented by a*x + b*y + c = 0

having two points (x1,y1) and (x2,y2) you can find a,b,c (except for an
arbitrary scale factor).

The orthogonal distance of an arbitrary point (x,y) to that same line is given
by a*x + b*y + c which is obviously zero for all points on the line.

So for hit testing I would:
- calculate a,b,c once
- checking a*x + b*y + c is sufficiently small
- for a finite line segment: also checking x is in an acceptable range
smallest of x1 and x2 minus some, largest of them plus some; same for y.

BTW: officially you should normalize the scale factor such that e.g.
a*a+b*b+c*c=1; in reality you can skip that and replace the distance check by:
(a*x + b*y + c)^2 small with respect to a*a+b*b+c*c


FYI: there is a completely different way to do all this:

create a memory-based bitmap where you draw the same line with a much thicker pen,
of a selected color; now just sample the color at (x,y) to see whether it is
part of the thick line. This also works for more complex shapes and drawings
provided you use different colors for different pickables (a problem will arise
where they overlap though).

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]


Sorry for any delays in replying, I currently don't get e-mail notifications.


GeneralRe: Math problem Pin
Mike Hankey10-Dec-07 4:04
mveMike Hankey10-Dec-07 4:04 
GeneralRe: Math problem Pin
CKnig10-Dec-07 18:20
CKnig10-Dec-07 18:20 
GeneralRe: Math problem Pin
Mike Hankey11-Dec-07 5:03
mveMike Hankey11-Dec-07 5:03 
GeneralDatatypes conversion [modified] Pin
VK-Cadec10-Dec-07 2:35
VK-Cadec10-Dec-07 2:35 
GeneralRe: Datatypes conversion Pin
J4amieC10-Dec-07 2:58
J4amieC10-Dec-07 2:58 
Questiontextbox-datagridview Pin
avvaru.murali10-Dec-07 2:30
avvaru.murali10-Dec-07 2:30 
GeneralRe: textbox-datagridview Pin
Paul Conrad10-Dec-07 10:47
professionalPaul Conrad10-Dec-07 10:47 
GeneralResource checking Pin
sindhutiwari10-Dec-07 2:07
sindhutiwari10-Dec-07 2:07 
GeneralAgain about certifications Pin
allende10-Dec-07 1:52
allende10-Dec-07 1:52 
Generalincrmenting by 01 instead of 1 Pin
eyeseetee10-Dec-07 1:45
eyeseetee10-Dec-07 1:45 
GeneralRe: incrmenting by 01 instead of 1 Pin
Bekjong10-Dec-07 1:53
Bekjong10-Dec-07 1:53 
GeneralRe: incrmenting by 01 instead of 1 Pin
J4amieC10-Dec-07 1:58
J4amieC10-Dec-07 1:58 
GeneralRe: incrmenting by 01 instead of 1 Pin
Anthony Mushrow10-Dec-07 2:20
professionalAnthony Mushrow10-Dec-07 2:20 
GeneralRe: incrmenting by 01 instead of 1 Pin
eyeseetee10-Dec-07 2:56
eyeseetee10-Dec-07 2:56 
GeneralRe: incrmenting by 01 instead of 1 Pin
J4amieC10-Dec-07 3:09
J4amieC10-Dec-07 3:09 
GeneralRe: incrmenting by 01 instead of 1 Pin
eyeseetee10-Dec-07 3:22
eyeseetee10-Dec-07 3:22 
GeneralRe: incrmenting by 01 instead of 1 Pin
eyeseetee10-Dec-07 3:27
eyeseetee10-Dec-07 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.