Sei sulla pagina 1di 9

Bezier curve

A Bezier curve is a mathematically defined curve used in two-dimensional graphic


applications. The curve is defined by four points: the initial position and the
terminating position (which are called "anchors") and two separate middle points
(which are called "handles"). The shape of a Bezier curve can be altered by
moving the handles. The mathematical method for drawing curves was created by
Pierre Bézier in the late 1960's for the manufacturing of automobiles at Renault.

What's a Bézier Curve?

A Bezier curve in its most common form is a simple cubic equation that can be
used in any number of useful ways. Originally developed by Pierre Bézier in
the 1970's for CAD/CAM operations, it became the underpinnings of the entire
Adobe PostScript drawing model. If you're a regular user of Adobe Illustrator,
Macromedia Freehand or Fontographer, any number of spline-based 3D
programs, etc., you've probably used Bézier curves.

It can also be used for animation. These pages are a simple introduction to how
to implement Béziers for motion control: how to choose curves and control
points, and how to calculate movement along the curve. I've provided a sample
Shockwave movie you can try out, download, and grub around in the code of.
The Math Behind the Bézier Curve

A cubic Bezier curve is defined by four points. Two are endpoints. (x0,y0) is the
origin endpoint. (x3,y3) is the destination endpoint. The points (x1,y1) and (x2,y2)
are control points.

Two equations define the points on the curve. Both are evaluated for an
arbitrary number of values of t between 0 and 1. One equation yields values for
x, the other yields values for y. As increasing values for t are supplied to the
equations, the point defined by x(t),y(t) moves from the origin to the
destination. This is how the equations are defined in Adobe's PostScript
references.

x(t) = axt3 + bxt2 + cxt + x0

x1 = x0 + c x / 3
x2 = x1 + (cx + bx) / 3
x3 = x0 + cx + bx + ax

y(t) = ayt3 + byt2 + cyt + y0

y1 = y0 + c y / 3
y2 = y1 + (cy + by) / 3
y3 = y0 + cy + by + ay

This method of definition can be reverse-engineered so that it'll give up the


coefficient values based on the points described above:

cx = 3 (x1 - x0)
bx = 3 (x2 - x1) - cx
ax = x3 - x0 - cx - bx
cy = 3 (y1 - y0)
by = 3 (y2 - y1) - cy
ay = y3 - y0 - cy - by

Now, simply by knowing coördinates for any four points, you can create the
equations for a simple Bézier curve.

Loops

By grossly distorting the values for origin, destination, and control points, it's
possible to create curves that approximate parabolas, arcs, and even loops.
(Remember when you're programming that you don't have to limit your control
points to valid stage locations!)

By stringing two or more Bézier curves together, evaluating each from 0 to 1 in


sequence, a multitude of shapes can be drawn (after all, if you can draw the
shape in an illustration program, you're drawing it with Béziers).

Take some time to experiment with our Shockwave Bézier demo (requires
Shockwave for Director 5). Put Béziers to work for you today!
Straight Lines

This example shows a straight line animation using a Bézier curve. As you can
see, the control points lie approximately 1/3 of the distance from their
associated endpoint to the other endpoint. This creates a smooth movement
from origin to destination. It would probably be simpler to animate this
movement with another method, though.

This animation, on the other hand, might be a little bit harder. As you can see
from the spacing of the iterated points, the dot starts moving, slows down, then
speeds up to twice its previous speed before stopping. If you look closely,
you'll see that the green and red control points are almost touching, about 1/3 of
the way from the origin to the destination.

Bézier curve equations are constructed in such a way that when the value for t
is 0.333...., the most influential of the four defining points will be x1,y1.
Likewise, at 0.666..., x2,y2 will hold sway.

Because of their (dare I say it?) flexibility, Bézier's equations are ideal for
creating smoothly animated acceleration and deceleration sequences, as well as
semi-complex curves.

Simple Curves
This example shows the default curve iterated by the sample movie. The small
black square moves from the origin point x0,y0 (large green dot) to the
destination point x3,y3 (large red dot), successively coming under the influence
of the control points: first the small green dot x1,y1, then the small red dot x2,y2.

The movement along this curve is fairly steady. There are 50 points along the
curve, with t increasing by 0.02 each iteration.

The curve's slope (or direction) at the origin is tangent to the line between x0,y0
and x1,y1. The same holds true for the slope at the destination and the line
between x2,y2 and x3,y3.

The length of the line between each endpoint and its associated control point
determines the speed of the movement along segments of the curve, as we'll see
when we look at how you can use Bézier curves to create straight-line
animations with acceleration and deceleration.
Stiffness Method

Introduction

Stiffness method is an efficient way to solve complex


determinant or indeterminant structures (Fig. 1). It is also
called finite element method, which is a powerful
engineering method and has been applied in numerous
engineering fields such as solid mechanics and fluid
mechanics. The idea of stiffness method is as following:

• Subdividing the structures into a series of discrete


elements
• Formulating the stiffness matrix for each of the
elements
Fig. 1 Frame structure • Assembling the global matrix
• Applying the boundary conditions to obtain the
reduced matrix
• Inverting the reduced matrix
• Multiplying the inverted reduced matrix with the
forces to get the displacements of the nodes

• Post-processing to obtain the stresses and strains


of elements

Truss Stiffness Matrix


For truss structures, each member is an element. In order to
assemble the matrices in a systematic way, all the truss
member stiffness matrices are formed in global coordinates.
Every member's stiffness matrix is formulated in the same
way which is as following:

Fig. 2 Truss element for stiffness


matrix

Where
A = Cross section area of the member
E = Elasticity modulus
L = Length of the member
C = cos(θ )
S = sin(θ )
k = Member stiffness method

Frame Stiffness Matrix

For frame structures, the stiffness matrix is more complex


than truss structures since the rotation is also considered.
Here only plane frame is considered. In order to derive the
frame stiffness matrix, the arbitrarily oriented beam
element's matrix is formed and then the axial effects are
included. Combining both, the frame stiffness matrix is
formulated as following:

Fig. 3 Plane frame element

(2)
Where
A = Cross section area of the element
E = Elasticity modulus
I = Moment of inertia
L = Length of the element
C = cos(θ )
S = sin(θ )
k = Element stiffness method

Assembling the Stiffness Matrices and Force Matrices

The global stiffness matrix can be obtained by summing the


stiffness matrix for each element, the formulation is

Where
K = Global stiffness matrix
k = Local element matrix
N = Total number of element
e = Index

Similarly, the force can be assembled as following:

Where
F = Global force matrix
f = Local force matrix
N = Total number of element
e = Index

Formulation of a System of Equations


To determine the displacements, the boundary conditions
are imposed and the following equation is solved.

Where
d = Displacement matrix

By post processing, the stresses, strains and nodal forces


can be obtained.

Potrebbero piacerti anche