Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Parallel

Rendering Line Drawings From 3D Models


Sep99: Bézier Curves

Bézier Curves

Making smooth, but complex appearing, curves and surfaces is of great interest in computer graphics. Bézier (or Bernstein) polynomials provide a way of making complex curves that are anchored at corner points and distorted by other control points that pull it towards them as if by gravity. Cubic polynomial Bézier curves are defined by four control points. Bézier curves are a function of one real parameter, say u. As u varies, conventionally from 0.0 to 1.0, the x and y values are defined continuously. The Bézier curve starts on the first point and ends on the fourth point. The two points in the middle pull the curve towards them a little, but the curve will not, in general, intersect the two middle points. The resulting curve is very smooth.

Bézier surfaces in three dimensions are defined by sets of Bézier curves and two parameters, say u and v. If one parameter is held constant, perhaps at 0.5, and the other one varied, the curve defined is a Bézier curve and is called "isoparametric."

In the room program, I made the curves with PARM_STEP_QTY (64) steps. The parameters u and v step from 0 to 1 in 65 steps. Then a b vector is built for both u and v at each value (that's 64×64 values total; if you stored these 65 vectors for u and v you could skip recomputing them.)

b[0]=(1-u)3

b[1]=3u(1-u)2

b[2]=3(u2)(1-u)

b[3]=u3

Notice how when u=0, then b[0] will be in control, and when u=1, b[3] will be in control; those are the end-points intersected by the curve I'm building. When u is between 0 and 1, the vectors b[1] and b[2] tug the curve toward them.

-- T.E.J.


Copyright © 1999, Dr. Dobb's Journal

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.