Click here to Skip to main content
15,911,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
SuggestionRe: Determine straight line Pin
Richard MacCutchan7-Aug-12 1:17
mveRichard MacCutchan7-Aug-12 1:17 
GeneralRe: Determine straight line Pin
tagopi7-Aug-12 1:29
tagopi7-Aug-12 1:29 
GeneralRe: Determine straight line Pin
Amarnath S7-Aug-12 1:18
professionalAmarnath S7-Aug-12 1:18 
One way would be by using slope. Find the slope of the line corresponding to the first two points (y-coord of p2 - y-coord of p1) / (x-coord of p2 - x-coord of p1).
Find the slopes of the lines corresponding to all other points (with respect to the first point), say (y-coord of pk - y-coord of p1) / (x-coord of pk - x-coord of p1), where k varies from 3 to n.

All of these slopes should be within a reasonable tolerance band. And, since all of these lines pass through p1, they all would lie on the same straight line if they fell within the tolerance band.

The above would not work if the x-coordinates of p2 and p1 are the same (because denominator would be zero). In that case, you choose a point whose x-coordinate is unique as the reference point.

Not sure whether this is the most efficient way, but it certainly a way of achieving what you want.
GeneralRe: Determine straight line Pin
tagopi7-Aug-12 1:30
tagopi7-Aug-12 1:30 
GeneralRe: Determine straight line Pin
Amarnath S7-Aug-12 1:45
professionalAmarnath S7-Aug-12 1:45 
GeneralRe: Determine straight line Pin
tagopi7-Aug-12 1:49
tagopi7-Aug-12 1:49 
GeneralRe: Determine straight line Pin
Eugen Podsypalnikov7-Aug-12 4:14
Eugen Podsypalnikov7-Aug-12 4:14 
GeneralRe: Determine straight line Pin
Amarnath S7-Aug-12 1:51
professionalAmarnath S7-Aug-12 1:51 
SuggestionRe: Determine straight line Pin
Albert Holguin7-Aug-12 1:40
professionalAlbert Holguin7-Aug-12 1:40 
GeneralRe: Determine straight line Pin
tagopi7-Aug-12 1:50
tagopi7-Aug-12 1:50 
AnswerRe: Determine straight line Pin
pasztorpisti7-Aug-12 5:57
pasztorpisti7-Aug-12 5:57 
AnswerRe: Determine straight line Pin
CPallini7-Aug-12 21:17
mveCPallini7-Aug-12 21:17 
QuestionC++ middleware with GUI in C Pin
Member 83997696-Aug-12 20:02
Member 83997696-Aug-12 20:02 
AnswerRe: C++ middleware with GUI in C Pin
Richard MacCutchan6-Aug-12 20:59
mveRichard MacCutchan6-Aug-12 20:59 
GeneralRe: C++ middleware with GUI in C Pin
Member 83997696-Aug-12 21:58
Member 83997696-Aug-12 21:58 
GeneralRe: C++ middleware with GUI in C Pin
Richard MacCutchan6-Aug-12 22:46
mveRichard MacCutchan6-Aug-12 22:46 
GeneralRe: C++ middleware with GUI in C Pin
JohnAspras6-Aug-12 21:21
JohnAspras6-Aug-12 21:21 
GeneralRe: C++ middleware with GUI in C Pin
Software_Developer6-Aug-12 22:42
Software_Developer6-Aug-12 22:42 
AnswerRe: C++ middleware with GUI in C Pin
pasztorpisti7-Aug-12 11:53
pasztorpisti7-Aug-12 11:53 
GeneralRe: C++ middleware with GUI in C Pin
Member 83997697-Aug-12 19:18
Member 83997697-Aug-12 19:18 
GeneralRe: C++ middleware with GUI in C Pin
pasztorpisti7-Aug-12 21:13
pasztorpisti7-Aug-12 21:13 
GeneralNeed help for a Ray Cast Function Pin
SD1016-Aug-12 8:15
SD1016-Aug-12 8:15 
GeneralRe: Need help for a Ray Cast Function Pin
Wes Aday6-Aug-12 8:20
professionalWes Aday6-Aug-12 8:20 
GeneralRe: Need help for a Ray Cast Function Pin
Software_Developer6-Aug-12 9:02
Software_Developer6-Aug-12 9:02 
Questionvectors Pin
Xarzu6-Aug-12 7:10
Xarzu6-Aug-12 7:10 

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.