?
Solved

vc++ splines & point structure

Posted on 2003-03-05
4
Medium Priority
?
354 Views
Last Modified: 2008-02-01
In a previous question about splines in vc++ (not using MFC), I got this response:
----------------------------------------------------------

PolyBezier (hdc, apt, iCount) ;

or


PolyBezierTo (hdc, apt, iCount) ;

In both cases, apt is an array of POINT structures. With PolyBezier, the first four points indicate (in this order) the begin point, first control point, second control point, and end point of the first Bezier curve. Each subsequent Bezier requires only three more points because the begin point of the second Bezier curve is the same as the end point of the first Bezier curve, and so on. The iCount argument is always one plus three times the number of connected curves you're drawing.

The PolyBezierTo function uses the current position for the first begin point. The first and each subsequent Bezier spline requires only three points. When the function returns, the current position is set to the last end point.

One note: when you draw a series of connected Bezier splines, the point of connection will be smooth only if the second control point of the first Bezier, the end point of the first Bezier (which is also the begin point of the second Bezier), and the first control point of the second Bezier are colinear; that is, they lie on the same straight line.
--------------------------------------------------------

I want to know if anyone can tell me how do I instantiate a point structure for use in those functions?

--------------------------------------------------------

An addition to my question, the point structure type is "tagPOINT".

I was able to declare:

tagPOINT apt[4];

then I was successfully able to compile and run:

apt[0].x=50;
apt[0].y=50;
apt[0].x=10;
apt[0].x=10;
apt[0].x=60;
apt[0].x=20;
apt[0].x=90;
apt[0].x=30;
iCount=1;

Then I call

PolyBezier (DC, apt, iCount) ;

in my LRESULT CALLBACK WndProc(HWND hWnd,UINT uMessage, WPARAM wParam, LPARAM lParam) function.

Everything compiles and runs, but nothing is drawn on the screen.

Any help is greatly appreciated.  I think this question is easy and I'm just missing something obvious, so currently it's only 50 points.  However, I will gladly raise the points if your answer is harder than I expected.

Thanks.




0
Comment
Question by:substand
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
Chase707 earned 200 total points
ID: 8077042
You should be able to just use this:

POINT apt[4];

Also, I don't think you aren't declaring your points correctly.  Each point is only an x,y -- therefore, for each x,y that you define, you need to increment your array counter:

apt[0].x=50;
apt[0].y=50;

apt[1].x=10;
apt[1].y=10;

apt[2].x=60;
apt[2].y=20;

apt[3].x=90;
apt[3].y=30;

Your iCount in this case should be 4.

try that out and see how it works.

Chase
0
 
LVL 10

Author Comment

by:substand
ID: 8077095
jeez.  i feel like such a moron now.  I didn't notice that I had copied the code and forgot to change the indexes on the array, and had forgot to change the x/y.

Wasted my points, but i still give you credit for pointing it out =)

thanks.

0
 
LVL 10

Author Comment

by:substand
ID: 8077109
This was a stupid question on my part.
i should have looked at my code a little longer before i posted it.
0
 
LVL 4

Expert Comment

by:Chase707
ID: 8077166
don't feel too bad....it happens to everyone now and then.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question