# How do I generate points for custom curve?

Basically, what I am doing is generating some curves based on a few points, then, I want to get an array of points of the finished curve. I want to do this in C#.

Graphics.DrawCurve and Graphics.DrawBezier do exactly what I want, except they draw the curves onto an object when I just want an array of points.

Also, the curves are not mathematical functions, many will be like this:
curve1.gif

Further clarification will be given if needed.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Also, the curves are not mathematical functions
No offense, but they actually are. They just aren't simple functions that we saw in algebra.
If you look, you'll see that while the entire curve would be hard to find a function for, the curve can certainly be broken into chunks that can be expressed with simple(ish) functions.
DrawCurves and DrawBezier do exactly that (use mathematical techniques to approximate the functions).
You could look up a lot of research on curve fitting and fit the curves yourself, but since the functions are already there, just draw the objects from the DrawCurves and DrawBezier functions onto a temp image (that is never displayed) and then iterate through that image to find the pixels.
0
Commented:
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Senior DeveloperCommented:
Really, the task you are asking to solve- almost impossible to solve.

Do you know what algorithms are used by DrawCurve, eg., to calculate coordinates of points? No. I don't know either. At least, for sure. Of course, I can guess... But implementation may change - no one guaranteed...

Anyway, you may need to write your own method based on an existing algorithm:
http://www.cs.drexel.edu/~david/Classes/CS430/Lectures/L-08_BezierDrawing.pdf

The above is just outline but gives an idea. Pretty tricky, I'd say :)

really, tpayn sayed basicly same... You just can't get points from existing method.
0
Commented:
Or you could draw the curve on a temp image and then parse through that image and find which points were drawn. It's not incredibly efficient, but it will certainly work.
0
Senior DeveloperCommented:
I'd say TommySzalapski's proposal is more real to implement. Not sure about performance though...
0
Author Commented:
Led me to solution, but really just posted a link
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.