# 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?

Commented:
0

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:
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

Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.