15,501,351 members
Home / Discussions / C / C++ / MFC

# C / C++ / MFC

 Re: internationalisation Abhi Lahare13-Jun-11 7:49 Abhi Lahare 13-Jun-11 7:49
 Re: internationalisation Kyudos14-Jun-11 11:50 Kyudos 14-Jun-11 11:50
 Re: internationalisation Abhi Lahare14-Jun-11 12:29 Abhi Lahare 14-Jun-11 12:29
 Want to find Rightmost top point from the CPoint List Abhijit_Satpute9-Jun-11 9:27 Abhijit_Satpute 9-Jun-11 9:27
 Re: Want to find Rightmost top point from the CPoint List MicroVirus9-Jun-11 11:03 MicroVirus 9-Jun-11 11:03
 Re: Want to find Rightmost top point from the CPoint List Richard MacCutchan9-Jun-11 11:32 Richard MacCutchan 9-Jun-11 11:32
 Re: Want to find Rightmost top point from the CPoint List CPallini9-Jun-11 23:09 CPallini 9-Jun-11 23:09
 Re: Want to find Rightmost top point from the CPoint List Stefan_Lang15-Jun-11 3:46 Stefan_Lang 15-Jun-11 3:46
 If I understand you correctly, you want to find the point that is the farthest ina a particular direction. By the way you ask I assume you are not looking for the rightmost or topmost point, but a point that is 'closest to the top right corner', or something like that. I am thinking what you need is to define the direction you are looking at as a vector (in a geometrical sense), and then use vector algebra to determine which of the points is farthest in the direction denoted by that vector. To do this, you use that direction to define a line, and project all points onto that line, then determine its distance to the lines origin. It doesn't really matter where that origin lies as long as you differentiate which side of the origin your projected point comes to lie by using a signed distance value; for sake of simplicity just use (0,0) as origin. A line through (0,0) in the direction of D can be defined by L(t)=t*D. Calculating the projection Q of a point P on this line can be done like this: Q = (P*D / |D|) * D / |D| = (P*D)*D / (D*D). Basically this formula defines the parameter t for the peojected point Q to be t(Q)=(P*D)/(D*D). For the purpose of looking for the point 'farthest' in the direction of D, you can just compare the values of t(Q). And since the denominator (D*D) is a constant, you can just ignore it. Instead just calculate P*D for each point P and determine the point with the largest result: ```struct point2 { int x; int y; } int operator*(const point2& p1, const point2& p2) { return p1.x*p2.x + p1.y*p2.y; } void test() { std::list pointlist; point2 P; P.x = 1258; P.y = 263; pointlist.push_back(P); P.x = 1263; P.y = 260; pointlist.push_back(P); point2 D; D.x = 1; D.y = 1; std::list::iterator it = pointlist.begin() double farthest_value = (*it) * D; std::list::iterator farthest_point = it; while (++it != pointlist.end()) { double value = (*it) * D; if (value > farthest_value) { farthest_value = value; farthest_point = it; } } std::cout << "farthest point is (" << farthest_point.x << "," << farthest_point.y << ")" << std::endl; }```
 Using C# in C++ Chris_Green9-Jun-11 0:54 Chris_Green 9-Jun-11 0:54
 Re: Using C# in C++ CPallini9-Jun-11 1:24 CPallini 9-Jun-11 1:24
 Re: Using C# in C++ Chris_Green9-Jun-11 1:54 Chris_Green 9-Jun-11 1:54
 Re: Using C# in C++ Rolf Kristensen9-Jun-11 9:43 Rolf Kristensen 9-Jun-11 9:43
 Re: Using C# in C++ CPallini9-Jun-11 23:03 CPallini 9-Jun-11 23:03
 Re: Using C# in C++ ThatsAlok13-Jun-11 22:14 ThatsAlok 13-Jun-11 22:14
 Re: Using C# in C++ ThatsAlok13-Jun-11 22:16 ThatsAlok 13-Jun-11 22:16
 Font Size Problem in Edit Control [SOLVED] vishalgpt8-Jun-11 20:37 vishalgpt 8-Jun-11 20:37
 Re: Font Size Problem in Edit Control Richard MacCutchan8-Jun-11 22:42 Richard MacCutchan 8-Jun-11 22:42
 Re: Font Size Problem in Edit Control vishalgpt8-Jun-11 23:16 vishalgpt 8-Jun-11 23:16
 Re: Font Size Problem in Edit Control Richard MacCutchan9-Jun-11 5:07 Richard MacCutchan 9-Jun-11 5:07
 Re: Font Size Problem in Edit Control vishalgpt9-Jun-11 8:04 vishalgpt 9-Jun-11 8:04
 Re: Font Size Problem in Edit Control Richard MacCutchan9-Jun-11 8:23 Richard MacCutchan 9-Jun-11 8:23
 Re: Font Size Problem in Edit Control vishalgpt9-Jun-11 8:32 vishalgpt 9-Jun-11 8:32
 Re: Font Size Problem in Edit Control Iain Clarke, Warrior Programmer9-Jun-11 9:03 Iain Clarke, Warrior Programmer 9-Jun-11 9:03
 Re: Font Size Problem in Edit Control vishalgpt10-Jun-11 18:28 vishalgpt 10-Jun-11 18:28
 how to get the code of OnLButtonDown and OnMouseMove etc in OnDraw method ? iampradeepsharma8-Jun-11 18:13 iampradeepsharma 8-Jun-11 18:13
 Last Visit: 31-Dec-99 19:00     Last Update: 28-Nov-22 22:50 Refresh ᐊ Prev1...1230123112321233123412351236123712381239 Next ᐅ