View Full Version : Drawing Curves

Richard145

02-05-2007, 08:39 AM

Please Help,

I have two points (x, y, and z coordinates) and would like to interpolate a curve between them. I am very new to the idea of Bezier curves, etc. Can someone please let me know what is the usual means that is used to interpolate a curve between two points using OpenGL?

Thanks in advance.

jtipton

02-05-2007, 04:36 PM

At a minimum you will need 3 points, since there are an infinite number of curves that pass through 2 points. 3 points will give you a quadratic bezier curve. Check out this link for the math involved:

http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Examination_of_cases

Richard145

02-05-2007, 05:31 PM

Thank you jtipton.

What if you only have 2 definite points? I know you said you need at least three, is there a mathematical formula to calculate an interpretation between those two? Given that the two points are end points and the parabola between them should be positive?

Thanks and please forgive if this is a silly question but I am new to the curve interpolation bit of OpenGL.

jtipton

02-05-2007, 09:58 PM

A bezier curve for 2 points is defined as a straight line. This is the simplest case of all the curves fitting those 2 points. You need a third point, even if you make it up. You could define something along the midline and get a decent 3rd point. But, it will be entirely artificial. Is there anything you can use to find a meaningful 3rd point? Area under the curve? Max distance from P3 to the line P1->P2?

Richard145

02-06-2007, 03:19 AM

Unfortunately, I am reading the information off of an external ASCII file and it does not have an obvious third line. It is a STEP file (.stp) and very convoluted. I guess it will take some more digging into the file.

Thank you for your time.

plasmonster

02-06-2007, 07:15 AM

One possibility is to take the midpoint of the line seg and add an arbitrarily scaled, orthogonal vector to it. If it doesn't matter which direction you go in, you could construct a suitable basis from the line seg itself; if you have a plane in mind, then use the normal, or the cross product of the normal and the line seg itself.

Examples of OpenGL Bezier curve rendering:

http://www.rush3d.com/reference/opengl-redbook-1.1/chapter11.html

Richard145

02-06-2007, 08:31 AM

Thanks to jtipton and Minsrel.

I will definately have to do some more work on the concept of curves using OpenGL.

Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.