# Points parallel to Bezier Curve

on
I am developing an application that uses OpenGL and I need to create a series of parallel QUAD_STRIPS. You can think of it as a curved road with multiple lanes and I need to draw each lane separately. These lanes need to follow a set Bezier curve (with 2 control points) that is located along the center stripe of the road.

I can calculate the points along this cubic Bezier curve, but I am looking for a way to calculate a like number of points along both edges of each lane that parallels the center stripe that have a consistent offset or lane width if you will. If it matters, the initial curve can have any orientation in the Cartesian plane.
Comment
Watch Question

Do more with

EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015

Commented:
A curve that's a fixed distance from a Bezier curve is not in general something as simple as another Bezier curve.
You might try just adding a perpendicular to the tangent, or try the methods here:
http://www.cis.usouthal.edu/~hain/general/Publications/Bezier/BezierFlattening.pdf
Commented:
Points will never be parallel to a line (center or otherwise.)

But you might draw a line perpendicular to your curve at a point on the curve and lay off a distance of 1/2 your lane width in both directions on that perpendicular. Select as many points on your curve as you think you need and connect all the added points with straight line segments. If the segments are not curvey enough for you, just select more points on the initial curve.
Commented:
You need to calculate perpendicular lines to the original curve then move the points of the curve out by some width. To calculate the perpendicular is actually not as hard as you might think. You find a tangent and then turn it 90 degrees by swapping and negating the X and Y (assuming that the curves is on the Z plane). The tangent is found by interpolating the direction between control points the same way you would interpolate between the position of each control point. By direction I mean the vectors from the start point to c1, c1 to c2, and c2 to the end point. Note that, under some conditions, doing this will cause the strip to overlap itself, that isn't a problem unless you want to render the curve with a texture or an edge. Also note that a cubic bezier (two control points) can cross itself in extreme cases.

Commented:
Since they are similar answers I will split the points. These solutions gave me another idea too. That is to find the angle of each segment in the original cure, then offset a point the width of the lane at the segment midpoint. With staggered points I can use a GL_TRIANGLE_STRIP instead. I can always adjust the number of segments in the original curve to maintain a smooth result. Since no dramatic curves are expected this should give a fairly good rendering. I will try it and see how it works under various conditions.

Commented:
Thanks for the points. I've actually written some code for doing just what you are doing, you have the right idea. The code I wrote was for a GPS device, to show road maps.

Do more with