Link to home
Start Free TrialLog in
Avatar of swestbrook60
swestbrook60

asked on

Points parallel to Bezier Curve

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.
Avatar of ozo
ozo
Flag of United States of America image

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
SOLUTION
Avatar of aburr
aburr
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of swestbrook60
swestbrook60

ASKER

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