Solved

# Points parallel to Bezier Curve

Posted on 2014-02-28
708 Views
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.
0
Question by:swestbrook60
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 84

Expert Comment

ID: 39896430
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
0

LVL 27

Assisted Solution

aburr earned 250 total points
ID: 39896686
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.
0

LVL 12

Accepted Solution

satsumo earned 250 total points
ID: 39898509
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.
0

Author Closing Comment

ID: 39900717
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.
0

LVL 12

Expert Comment

ID: 39900926
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.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn different types of Android Layout and some basics of an Android App.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
###### Suggested Courses
Course of the Month9 days, 3 hours left to enroll