views:

490

answers:

4

I am using Bezier curves to plot curves in a program I am making. I have five points. Here is a crude sketch of the curve I am trying to create. I'm trying to make a curve that goes through A,B,C,D. However, C is not a definite point, it is a suggestion of where the curve should pass through to make it look like a French Curve. C comes out from E at 45 degrees.

This is an illustration of what I am trying to do.

Does anyone have any suggestions on how to approximate a French Curve that would go through those points?

A: 

Bezier curves pass through the first and last control point specified, and the interior control points determine the shape. If you make a curve using ABCDE it will not pass through point C. But you could break it into two different curves, introducing a control point before and after C so you have A B B' C and C C' D E. Make B', C, and C' collinear so that the curve will have first order continuity.

jblocksom
+1  A: 

You need to use a Cubic Bezier. Cubic Beziers are defined by four points, but do not pass through the middle two points, they merely specify a vector for the Bezier. Unfortunately for you, there are an infinite number of Cubic Bezier curves that can go 'through' your four points.

Don Lancaster has written a document (pdf) about this. Which goes into some pretty interesting detail about the algorithms he use. It's in postscript which I doubt you're using, but at least the principals are there.

Here is an article out on CodeProject where they've built a library for doing what you're trying to do with C#.

blesh
A: 

I don't know if this is how I'm supposed to write follow-up questions, but my problem is that I only have those four points. I found a website that told my how to find control points that will go through those points, but you have to give it a "u" and a "v" (u being at what point in the curve the first point should be at, and v being the point in the curve where it should go through the second). The only problem with this is that it doesn't come out smooth like an arc. I was hoping there would be some way to make it come out more smooth.

My project is to generate sewing patterns, and I'm trying to draw the arc for where the sleeves go. When people make patterns, they use a "French curve" ruler to fit the points into a nice curve. I was hoping I would be able to programatically do something like that.

mrmeyers99
You can just edit or add to your original question. :)
Troubadour
I hadn't registered when I asked the question, and I couldn't figure out how to update it without having a login...
mrmeyers99
I can't comment up there where you commented. I guess you could say it's not in the curve. A person actually drawing out the pattern would use the French curve ruler to get point C. Not having four points though would make getting a cubic bezier curve impossible.
mrmeyers99
You can probably come up with decent values for *u* and *v* based on how far the four points are from each other.
Jason Orendorff
You might do better with even fancier math. For example, given any set of points you can construct a best-fit conic section through them. (But to be honest I've had little luck creating elegant curves or believable motion based on equations. I always end up adding heuristic hacks until it looks nice. Lack of experience, perhaps--I'm not a game programmer.)
Jason Orendorff
The thing is that these points will change every time I run the program, so that makes it hard to take the heuristic approach...
Michael
A: 

Given any three non-collinear points (A, B, D), you can draw an arc connecting them.

Given any three or four points you can construct a Bézier curve connecting them that looks rather nice. (You probably do not need to throw in an extra point C just to get the curve to look nice, but of course you can if you want.)

Precisely how to do this depends on the graphics library you're using. So what library are you using?

Jason Orendorff
I'm actually not using any libraries. It's for my Senior Project at school. I have to all the graphics by hand.
Michael
"by hand" meaning drawing with a pencil on paper? Maybe what you need is a set of French curves and a pantograph...
Jason Orendorff
"by hand" meaning pixel by pixel. :)
Michael