3D Object Representation

advertisement
3D Object Representation
Shmuel Wimer
Bar Ilan Univ., School of Engineering
June 2010
1
Spline Representation
Spline is a flexible strip used to produce a smooth curve through a set of
points. Splines are used to design curve and surface shapes like automobile
bodies, aircrafts, home appliances and more.
C ubic splines are m ost popular. given a set of n  1 control points
p k   x k , y k , z k  , k  0,1,
p0
pk
, n , a cubic interpolation fits the points.
p k 1
pn
x  u   a xu  bxu  c xu  d x , y  u   a yu  b yu  c yu  d y
3
2
3
2
z  u   a z u  b z u  c z u  d z , 0  u  1.
3
June 2010
2
2
At each of n-1 internal point we require that two successive curve sections
pass through that point and also the equality of their 1st and 2nd derivatives,
thus imposing 4(n-1) equations of 4n polynomial coefficients. Two more
equations are obtained from passing through the first and last points. The
last two equations can be obtained by requiring the 2nd derivative at first
and last points to be zero.
A major drawback is that a change in the position of one control point needs
recalculation of all coefficients. This is solved by specifying the tangent at
each control point. Then, a change in position of one point affects only two
sections of the curve. This is called Hermite interpolation.
P u    x u  , y u  , z u 
pk
p k 1
June 2010
P 0  pk
P0  Dpk
P 1   p k 1
P  1   D p k 1
D p k is parametric derivative (curve slope).
3
T here is P  u   a u  b u  c u  d , 0  u  1. T he x com ponent of P  u  is
3
2
x  u   a x u  b x u  cu  d and sim ilarily for y and z .
3
3
P  u    u
 p k  0

 
p k 1
1

 
 Dp k  0

 
D
p
3
k 1 

2
u
2
u
0
0
1
1
0
1
2
1
a 
 
b

1    ,
c 
 
d 
1 a 
  
1
b
 
0 c 
  
0  d 

2
P   u    3 u
a   2
  
b
3
  
c   0
  
d   1
2u
2
1
3
2
0
1
0
0
1
a 
 
b

0   
c
 
d 
1   pk 

 
p k 1
1


0   Dpk 

 
0   D p k 1 
MH
T he inverse boundary constraints matrix M H is called H erm ite matrix.
June 2010
4
T he curve segm ent betw een the constraint points p k and p k  1 is therefore
3
P  u    u
u
2
u
 pk 


p k 1


 Dpk 


D
p
k 1 

1   M H
p k  2 u  3u  1   p k 1   2 u  3u
3
2
3
H 0 u 
2
2
H 2 u 
3
2
H1
H0
H1 u 
 D p k  u  2 u  u   D p k 1  u  u
3


H 3 u 
H4
H i  u  , i  0,1, 2, 3, are called
H3
H erm ite B len d in g F u n ction s.
June 2010
5
Other Splines
The requirements of curve derivative values control point may be a problem.
Instead, the derivatives can naturally be defined based on the control points.
In Cardinal splines a curve section is completely defined by the position of
four consecutive points.
pk
p k 1
P 0  pk ,
P0 
1
P 1   p k 1 ,
P0 
1
2
2
1  t   p k  1  p k 1  ,
1  t   p k  2  p k  .
t is called ten sion param eter, controlling how
p k 1
June 2010
p k 2
loosely or tightly it fits the control p oints.
6
t < 0: looser curve
t > 0: tighter curve
Cardinal matrix and blending functions are derived similarly as in Hermite
splines. Setting s=(1-t)/2
June 2010
7
P  u    u
3
u
2
u
 s

2s

1  
 s

 0
2s
s2
s3
3  2s
0
s
1
0
s   p k 1 

 
pk
s


0   p k 1 

 
0  p k  2 
MC
3
2
3
2
p k 1   su  2 su  su   p k   2  s  u   s  3  u  1 
CAR 0 u 
CAR 1 u 
3
2
3
2
 p k  1   s  2  u   3  2 s  u  su   p k  2  su  su 
CAR 2 u 
CAR 3 u 
C A R i  u  , i  0,1, 2, 3, are called C ard in al B len d in g F u n ction s.
June 2010
8
There are few more splines with more parameters than tension, designed
to model animation paths with abrupt changes in motion.
June 2010
9
Bezier Spline Curves
Developed by Pierre Bezier at Renault corporation for the design of automobile
bodies. Bezier splines are very useful for design of curves and surfaces.
Let p k   x k , y k , z k  , 0  k  n , be n  1 control points, blended
to create a position vector P  u  describing a path from p 0 to p n .
P u  

n
k 0
p k B E Z k , n  u  , 0  u  1, w here
B E Z k ,n  u   C  n , k  u
k
1  u 
nk
, C  n, k  
n!
k ! n  k  !
Bezier curve is a polynomial of degree one less the number of control points.
Coefficients and blending functions satisfy recursive relations as follows:
June 2010
10
C  n, k  
n  k 1
k
C  n , k  1 , n  k
B E Z k , n  u    1  u  B E Z k , n 1  u   u B E Z k 1, n 1  u  , n  k  1, w ith
B E Z k ,k  u   u
k
and B E Z 0 , k  u   1  u  .
k
p1
p1
p0
June 2010
p2
p2
p0
p3
p0
p7
11
Properties of Bezier Curves
A useful property is that the curve conn ects to first and last control
points: P  0   p 0 , P 1   p n .
T he param etric derivative at the end con trol points is given by:
P   0    n p 0  n p 1 , P  1    n p n 1  n p n .
T he slope of the cure at the end points is along the line joining the
last tw o end points.
T he param etric second derivatives is giv en by:
P   0   n  n  1    p 2  p 1    p 1  p 0   ,
P   1   n  n  1    p n  2  p n 1    p n 1  p n   ,
June 2010
12
A nother im portant property of any B ezier curve is its containm ent in the
convex hall of the control point. T his f ollow s from P  u  being a positive
sum of the control points w here sum of w eights is

n
k 0
B E Z k , n  u   1.
Cubic Bezier Curves
Bezier curves with many points are expensive to compute due to high degree
of polynomials. It is common to “patch” curves of four points and construct it
from piecewise cubic curves.
B E Z 0 ,3  1  u  , B E Z 1,3  3 u 1  u  , B E Z 2 ,3  3 u
3
2
2
1  u  ,
B E Z 3,3  u .
3
The following illustrates the four blending functions and how they relate to
various curves.
June 2010
13
June 2010
14
P olynom ial
P  u    u u
expansion yields:
3
2
 1

3

u 1  
 3

 1
3
3
6
3
3
0
0
0
1  p0 

 
p1
0


0  p2 

 
0  p3 
M B ez
Complex curves can be constructed by patching cubic Bezier splines. Given
two control points, in order to obtain C1 continuity of the patch a new point
is introduced and its position is defined by equation the expression of first
derivative for u=1 with the next one for u=0. If C2 continuity is desired, a
second point is introduces and the expressions of the second derivatives
are also equated.
June 2010
15
Displaying Spline Curves and Surfaces
We must determine positions of points on curves and surfaces for displaying
those. Parametric polynomial splines must be calculated by steps increments
over range of parameter, e.g. [0,1]. This is very time consuming and efficient
computations methods are in order.
C onsider a cubic spline
x  u   a x u  b x u  c x u  d x . A pplying
3
2
H orn er's ru le x  u     a x u  b x  u  c x  u  d x requires 4 additions
and 3 m ultiplications. T his m ust be re peared for every displayed
point, w hich is ver y expensive.
A method called Forward-Difference is very efficient and requires mostly
additions.
June 2010
16
L et us increase u   0,1  in steps u 0  0, u k  1  u k   , k  0,1, 2,
T his results corresponding increm ents x k  1  x k   1 x k i n x . S ubstitution
of u k   in x  u  yields:
x k 1  a x  u k  

3
 bx  u k  

2
 cx uk     d x 
a x u k  b x u k  c x u k  d x  3 a x u k   3 a x  2 b x  u k   a x  b x
3
2
2
2
3
2
 c x

 1 xk
xk
 1 x k is quadratic polynom ial of u .  1 x k  1   1 x k   2 x k . S ubstitu tion
of u k   in  1 x k yields
 1 x k  u k    = 3 a x  u k  

2
  3 a x  2 b x
 1 x k  u k   6 a x u k   6 a x  2 bx
2
June 2010
3
 2 xk
2
 u
     a x  b x  c x  
3
k
2
2
17
S im ilarily,
 2 xk  u k  
  6 a x  u k     2  6 a x 3  2 bx 2
  2 x k  6 a x
3
 3 xk
A t x 0 there exists u 0  0. H ence x 0  d x ,  1 x 0  a x   b x   c x  ,
3
 2 x0  6 a x  2 b x
3
2
2
and 6 a x  .
3
T hen x1  x 0   1 , x 2  x1   1   2 , and x 3  x 2   1   2   3 .
x 4 can be derived from x1 by considering x1 a s a starting point
and progressing w ith 3 forw ard differenc es.
H ence x i  3  x i  3  1  2  2   3 , requiring only 3 add itions for
eavery new point.
June 2010
18
Download