Click here to Skip to main content
15,916,042 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Those *#@!$+ Memory Leaks Pin
Uwe Keim19-May-05 10:23
sitebuilderUwe Keim19-May-05 10:23 
GeneralRe: Those *#@!$+ Memory Leaks Pin
jmkhael19-May-05 21:53
jmkhael19-May-05 21:53 
GeneralRe: Those *#@!$+ Memory Leaks Pin
Uwe Keim20-May-05 3:28
sitebuilderUwe Keim20-May-05 3:28 
GeneralRe: Those *#@!$+ Memory Leaks Pin
David Crow19-May-05 8:31
David Crow19-May-05 8:31 
GeneralRe: Those *#@!$+ Memory Leaks Pin
Uwe Keim19-May-05 10:22
sitebuilderUwe Keim19-May-05 10:22 
GeneralRe: Those *#@!$+ Memory Leaks Pin
Uwe Keim20-May-05 3:25
sitebuilderUwe Keim20-May-05 3:25 
QuestionVS ANSI C++ implementation error? Pin
Franz Klein19-May-05 5:36
Franz Klein19-May-05 5:36 
AnswerRe: VS ANSI C++ implementation error? Pin
David Crow19-May-05 5:49
David Crow19-May-05 5:49 
AnswerRe: VS ANSI C++ implementation error? Pin
PJ Arends19-May-05 7:49
professionalPJ Arends19-May-05 7:49 
Generalsmall pointers problem Pin
Mridang Agarwalla19-May-05 5:16
Mridang Agarwalla19-May-05 5:16 
GeneralRe: small pointers problem Pin
David Crow19-May-05 5:47
David Crow19-May-05 5:47 
GeneralRe: small pointers problem Pin
RChin19-May-05 5:55
RChin19-May-05 5:55 
GeneralRe: small pointers problem Pin
ThatsAlok19-May-05 19:05
ThatsAlok19-May-05 19:05 
GeneralDirectory existance Pin
Imtiaz Murtaza19-May-05 5:13
Imtiaz Murtaza19-May-05 5:13 
GeneralRe: Directory existance Pin
Blake Miller19-May-05 5:16
Blake Miller19-May-05 5:16 
GeneralRe: Directory existance Pin
Ravi Bhavnani19-May-05 5:41
professionalRavi Bhavnani19-May-05 5:41 
GeneralRe: Directory existance Pin
ThatsAlok19-May-05 18:25
ThatsAlok19-May-05 18:25 
GeneralProblem with controlling window media player Pin
JaniceA19-May-05 5:06
JaniceA19-May-05 5:06 
GeneralRun program on startup Pin
Zack Manning19-May-05 4:52
sussZack Manning19-May-05 4:52 
GeneralRe: Run program on startup Pin
Blake Miller19-May-05 5:18
Blake Miller19-May-05 5:18 
GeneralRe: Run program on startup Pin
ddmcr19-May-05 7:11
ddmcr19-May-05 7:11 
GeneralPolyBezier Pin
Anthony988719-May-05 4:37
Anthony988719-May-05 4:37 
GeneralRe: PolyBezier Pin
Joel Holdsworth19-May-05 6:51
Joel Holdsworth19-May-05 6:51 
Ok... I think you are going down the right path with PolyBezier. But you have to think a bit about how beziers work. There's an article here[^] on the subject (ignore the code at the bottom - windows implements that for you!). So each point on the polygon has two bezier handles associated with it... one for the next line segment, and on for the previous. Now what I think Excel does is choose the positions of those bezier handles for you automatically. The two points are in a smooth arrangement - so the the polygon point, and the two bezier handles form a straight line. The distance between the handle and polygon point is chosen in proportion to the length of the line segmet it applies to. With me so far?

Additionally the line formed by the polygon point and the two bezier handles is angled in way to be sort of tangential to the polygons. It seems to take an average between the angle of the first and last segments (whether weigthed by length I'm not sure).

so I think you need to do something like this:

void DrawSmoothedPolygon(HDC dc, POINT *pointlist, int pointcount)
{
   const float curvyness = 0.1f;

   float prevseglength, nextseglength;
   long dx, dy;
   long leapfrogdx, leapfrogdy;

   ASSERT(pointlist != NULL);
   ASSERT(pointcount >= 3);

   POINT *curvepoints = new POINT[pointcount * 3 + 1];

   curvepoints[0] = pointlist[i];
   curvepoints[1] = pointlist[i];
   curvepoints[pointcount * 3 + 1] = pointlist[pointcount];
   curvepoints[pointcount * 3] = pointlist[pointcount];

   dx = (curvepoints[1].x - curvepoints[0].x);
   dy = (curvepoints[1].y - curvepoints[0].y);

   nextseglength = sqrt(dx*dx + dy*dy);
   
   for(int i = 1; i < pointcount - 1; i++)
   {
      leapfrogdx = (curvepoints[i-1].x - curvepoints[i+1].x);
      leapfrogdy = (curvepoints[i-1].y - curvepoints[i+1].y);

      preveglength = nextseglength;
      dx = (curvepoints[i+1].x - curvepoints[i].x);
      dy = (curvepoints[i+1].y - curvepoints[i].y);
      nextseglength = sqrt(pointlist[i].x * pointlist[i].x + pointlist[i].y * pointlist[i].y);

      curvepoints[i * 3] = pointlist[i];

      curvepoints[i * 3 + 1].x = pointlist[i].x + leapfrogdx / (nextseglength / curvyness);
      curvepoints[i * 3 + 1].y = pointlist[i].y + leapfrogdy / (nextseglength / curvyness);
      curvepoints[i * 3 - 1].x = pointlist[i].x - leapfrogdx / (prevseglength / curvyness);
      curvepoints[i * 3 - 1].y = pointlist[i].y - leapfrogdy / (prevseglength / curvyness);
   }

   PolyBezier(dc, curvepoints, pointcount * 3 + 1);
   delete[] curvepoints;
}
Now I'm not sure how well this will work. But it may give you some ideas to start with. Also it doesn't deal with closed curves... I'll leave you to figure those out Wink | ;)

Joel Holdsworth

Wanna give me a job this summer?
Check out my online CV and project history[^] - now available in MSWord format![^]
GeneralHelp needed to fix warning C4251 Pin
Kri519-May-05 3:55
Kri519-May-05 3:55 
GeneralRe: Help needed to fix warning C4251 Pin
Alexander M.,19-May-05 4:22
Alexander M.,19-May-05 4:22 

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.