1. Trang chủ
  2. » Toán

Bài giảng Đồ họa máy tính: Bài 7 - Lê Tấn Hùng

7 12 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 776,13 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Uniform/Periodic B-splines : The spacing is unform and the knots (control points) are equispaced e.g. [0,1,2,3,4,5] These have satisfactory smoothness but lack local control and the sta[r]

Trang 1

(c) SE/FIT/HUT 2002

Đường cong trong không gian

3D CURVE

Đường cong - Curve

Why use curves? Quỹ đạo chuyển động của 1 điểm trong không gian

Đường cong biểu diễn Điểm -curve represents points:

Điểm Biểu diễnvà kiểm soát đường cong -Points represent-and control-the curve.

Cách tiếp cận này là cơ sở của lĩnh vực Computer Aided Geometric Design (CAGD).

Phân loại

Trên cơ sở ràng buộc giữa điểm và đường trong cả ứng dụng khoa học và

thiết kế ta co thể phân làm 2 loại:

Xấp xỉApproximation

-Được ứng dụng trong mô hình hoá hình học

Nội suy-Interpolation

Trong thiết kế nôi suy là cần thiết với các đối tượng nhưng không phù hợp

với các đối tượng có hình dáng bất kỳ "free form“

Biểu diễn Đường cong

Tường minh y=f(x)

y = f(x), z = g(x) impossible to get multiple values for a single x

break curves like circles and ellipses into segments

not invariant with rotation

rotation might require further segment breaking

problem with curves with vertical tangents

infinite slope is difficult to represent Không tường minh f(x,y)=0 - Implicit equations:

f(x,y,z) = 0 equation may have more solutions than we want

circle: x² + y² = 1, half circle: ? problem to join curve segments together

difficult to determine if their tangent directions agree at their joint point

Đường cong tham biến

Biểu diễn các đường cong tham biến Parametric representation:

x = x(t), y = y(t), z = z(t)

overcomes problems with explicit and implicit forms

no geometric slopes (which may be infinite)

parametric tangent vectors instead (never infinite)

a curve is approximated by a piecewise polynomial curve

Define a parameter space

1D for curves

2D for surfaces

Define a mapping from parameter space to 3D points

A function that takes parameter values and gives back 3D points

The result is a parametric curve or surface

Mapping F :t → (x, y, z)

Parametric Curves

We have seen the parametric form for a line:

Note that x, y and z are each given by an equation that involves:

The parameter t Some user specified control points, x 0 and x 1

This is an example of a parametric curve

1 0

1 0

1 0

) 1 ( ) 1 ( ) 1 (

z t t z z

y t t y y

x t t x x

− +

=

− +

=

− +

=

Trang 2

(c) SE/FIT/HUT 2002 7

Đường cong đa thức bậc ba

Phải đảm bảo là đường cong không gian với 3 trục toạ độ x, y, z

tránh được những tính toán phức tạp và những phần nhấp nhô ngoài ý

muốn xuất hiện ở những đường đa thức bậc cao

Why cubic?

P0

p3

P0

P'1

Đ ường cong bậc 3

x = a 1 + b 1 u + c 1 u 2 + d 1 u 3

y = a 2 + b 2 u + c 2 u 2 + d 2 u 3

z = a 3 + b 3 u + c 3 u 2 + d 3 u 3

Với 3 điểm P0, P1, P2, P3 phương trình xác định

Hermite Spline

A spline is a parametric curve defined by control points

The term spline dates from engineering drawing, where a spline was a piece

of flexible wood used to draw smooth curves

The control points are adjusted by the user to control the shape of the curve

Phương pháp Hermite dựa trên cơ sở của cách biểu diễn Ferguson hay Coons

năm 60

A Hermite spline is a curve for which the user provides:

The endpoints of the curve

The parametric derivatives of the curve at the endpoints

The parametric derivatives are dx/dt, dy/dt, dz/dt

That is enough to define a cubic Hermite spline, more derivatives are required

for higher order curves

Đường cong Hermite

p = p(u) = k0+ k1u + k2u2+ k3u3

p(u) = ∑kiui i∈n

p0 và p1ta có hai độ dốc p0’ và p1’ với u = 0 và u = 1 tại hai điểm đầu cuối của đoạn [0,1].

We have constraints:

The curve must pass through p0 when u=0 The derivative must be p’ 0 when u=0

The curve must pass through p1 when u=1 The derivative must be p’ 1 when u=1

Basis Functions

A point on a Hermite curve is obtained by multiplying each control point

by some function and summing

p = p(u) = p0(1-3u2+2u3) + p1(3u2-2u3)

+ p0’(u-2u2+u3) + p1’(-u2+u3)

p = p(u) = [ 1 u u2 u3]

Trang 3

(c) SE/FIT/HUT 2002 13

Đường cong Bezier

Sử dụng điểm và các vector kiểm soát được độ dốc của đường

cong tại nhưng điểm mà nó đi qua.(Hermit)

không được thuận lợi cho việc thiết kế tương tác, không tiếp cận

vào các độ dốc của đường cong bằng các giá trị số (Hermite).

Paul Bezier, RENAULT, 1970 đường và bề mặt UNISURF

po, p3 tương đương với p0, p1 trên đường Hermite diểm trung gian p1, p2 được xác định bằng 1/3 theo độ dài của vector tiếp tuyến tại điểm po và p3

p0’ = 3(p1– p0)

p3’ = 3(p3– p2)

p = p(u) = p0(1-3u2+2u3) + p1(3u2-2u3) + p0’(u-2u2+u3) + p1

’(-u2+ u3)

p = p(u) = p0(1 - 3u + 3u2- u3) + p1(3u-6u2-3u3) + p2(3u2- 3u3) + p3u3

Biểu diễn Ma trận

p = p(u) = [ 1 u u2u3]

3 2 1 0

1 3 3 1

0 3 6 3

0 0 3 3

0 0 0 1

p p p p

0 0.2 0.4 0.6 0.8 1 1.2

B0 B1 B3

Ưu điểm

dễ dàng kiểm soát hi`nh dạng của đường cong hơn vector tiếp tuyến tại p0’ và p1’ của Hermite

Nằm trong đa giác kiểm soát với số điểm trung gian tuỳ ý( số bậc tuỳ ý)

đi qua điểm đầu và điểm cuối của đa giác kiểm soát, tiếp xúc với cặp hai vector của đầu cuối đó

Example

Bezier Curves

[UW]

Sub-Dividing Bezier Curves

P 0

P 3

M 01

M 12

M 23

M 012

M 123

M 0123

Trang 4

(c) SE/FIT/HUT 2002 19

Sub-Dividing Bezier Curves

P 0

P 3

Sub-Dividing Bezier Curves

Step 1: Find the midpoints of the lines joining the original control vertices

Call them M 01 , M 12 , M 23 Step 2: Find the midpoints of the lines joining M 01 , M 12 and M 12 , M 23 Call

them M 012 , M 123 Step 3: Find the midpoint of the line joining M 012 , M 123 Call it M 0123

The curve with control points P 0 , M 01 , M 012 and M 0123exactly follows the

original curve from the point with t=0 to the point with t=0.5 The curve with control points M 0123 , M 123 , M 23 and P 3exactly follows the

original curve from the point with t=0.5 to the point with t=1

de Casteljau’s Algorithm

You can find the point on a Bezier curve for any parameter value t with a similar

algorithm

Say you want t=0.25, instead of taking midpoints take points 0.25 of the way

P 0

P 3

M 01

M 12

M 23 t=0.25

Biểu thức Bezier-Bernstain

Tổng quát hoá với n +1 điểm kiểm soát

p0 pn : vector vị trí của đa giác n+1 đỉnh

) )(

( )

(

) ( ) (

1

0 , 1

0 ,

i i n

i i n

i n

i n i

P p u B n u p

p u B u p

=

=

+

=

i n i n

)!

i n ( i

! n ) i n ( C

=

Tính chất

P0 và Pn nằm trên đường cong

Đường cong liên tục và có đạo hàm liên tục tất cả các bậc

Tiếp tuyến của đường cong tại điểm P0 là đường P0P1 và tại

Pn là đường Pn-1Pn

Đường cong nằm trong đường bao lồi convex hull của các

điểm kiểm soát.

This is because each successive Pi(j) is a convex

combination of the points Pi(j-1) and Pi-1(j-1)

P1 ,P2 , … ,Pn-1 nằm trên đường cong khi và chỉ khi

đường cong là đoạn thẳng

Review:

Bézier Curve Prop’s [1/6]

We looked at some properties of Bézier curves

Generally “Good” Properties

Endpoint Interpolation Smooth Joining Affine Invariance Convex-Hull Property

Generally “Bad” Properties

Not Interpolating

No Local Control

Trang 5

(c) SE/FIT/HUT 2002 25

Problem with Bezier Curves

To make a long continuous curve with Bezier segments

requires using many segments

Maintaining continuity requires constraints on the control

point positions

The user cannot arbitrarily move control vertices and automatically

maintain continuity

The constraints must be explicitly maintained

It is not intuitive to have control points that are not free

Invariance

Translational invariance means that translating the control points and then

evaluating the curve is the same as evaluating and then translating the curve

Rotational invariance means that rotating the control points and then evaluating

the curve is the same as evaluating and then rotating the curve These properties are essential for parametric curves used in graphics

It is easy to prove that Bezier curves, Hermite curves and everything else we will study are translation and rotation invariant

Some forms of curves, rational splines, are also perspective invariant Can do perspective transform of control points and then evaluate the curve

Longer Curves

A single cubic Bezier or Hermite curve can only capture a small class of curves

At most 2 inflection points

One solution is to raise the degree

Allows more control, at the expense of more control points and higher degree

polynomials

Control is not local, one control point influences entire curve

Alternate, most common solution is to join pieces of cubic curve together into

piecewise cubic curves

Total curve can be broken into pieces, each of which is cubic

Local control: Each control point only influences a limited part of the curve

Interaction and design is much easier

Piecewise Bezier Curve

“knot”

P 0,0

P 0,3

P 1,0

P 1,3

Continuity

When two curves are joined, we typically want some degree of continuity

across the boundary (the knot)

C 0, “C-zero”, point-wise continuous, curves share the same point where they

join

C 1, “C-one”, continuous derivatives, curves share the same parametric

derivatives where they join

C 2, “C-two”, continuous second derivatives, curves share the same parametric

second derivatives where they join

Higher orders possible

Question: How do we ensure that two Hermite curves are C 1across a

knot?

Question: How do we ensure that two Bezier curves are C 0 , or C 1 , or C 2

across a knot?

Đường bậc ba Spline

Spline đi qua n điểm cho trước mà mỗi đoạn là đường bậc ba độc lập có độ dốc và độ cong liên tục tại mỗi điểm kiểm soát hay điểm nút

Với n điểm:n-1 đoạn với mỗi đoạn 4 vector hệ số 4(n-1) cho n-1 đoạn, và 2(n-1) điều kiện biên và n-2 điều kiện về độ dốc cùng n-2 về độ cong

Spline dùng để chỉ phương pháp biểu diễn đường cong mềm thông qua các đoạn cong tham biến bậc ba với các điều kiện liên tục tại các điểm đầu nút

Trang 6

(c) SE/FIT/HUT 2002 31

Spline

u0= 0 với : (u0 un-1) uj+1> uj

ui+1= ui + di+1

C0để không có sự gián đoạn giữa hai đoạn cong

C1tính liên tục bậc nhất hay đạo hàm bậc nhất tại điểm nối

C2đạo hàm bậc hai liên tục của đường cong tại điểm nối

Achieving Continuity

For Hermite curves, the user specifies the derivatives, so C 1is achieved simply by sharing points and derivatives across the knot

For Bezier curves:

They interpolate their endpoints, so C 0is achieved by sharing control points The parametric derivative is a constant multiple of the vector joining the first/last 2 control points

So C 1 is achieved by setting P 0,3 =P 1,0 =J, and making P 0,2 and J and P 1,1

collinear, with J-P 0,2 =P 1,1 -J

C 2 comes from further constraints on P 0,1and P1,2

Bezier Continuity

P 0,0

J

P 1,1

P 1,2

P 1,3

Disclaimer: PowerPoint curves are not Bezier curves, they are

interpolating piecewise quadratic curves! This diagram is an

approximation

B-splines

B-splines automatically take care of continuity, with exactly one control vertex per curve segment

Many types of B-splines: degree may be different (linear, quadratic, cubic,…) and they may be uniform or non-uniform

We will only look closely at uniform B-splines

With uniform B-splines, continuity is always one degree lower than the degree of each curve piece

Linear B-splines have C 0 continuity, cubic have C 2, etc

Đường cong B-spline

Đường cong B-spline là đường cong được sinh ra từ đa giác

kiểm soát mà bậc của nó không phụ thuộc vào số đỉnh của đa

giác kiểm soát.

B-Splines:

The Idea [1/2]

The repeated-lirping idea that produced the Bézier curves has the drawbacks that is produces polynomials with high degree that are nonzero almost everywhere

Using functions defined in pieces, we can fix these two

Start: An order-1 B-Spline has blending functions that are always either 1

or 0 When a function is 1, all the rest are zero

So an order-1 B-spline is just a sequence of points

Any number of control points may be used

Now we make higher-order B-splines using a repeated-lirping procedure

But this time, we can use any number of control points

Trang 7

(c) SE/FIT/HUT 2002 37

The Idea [2/2]

We form an order-2 B-Spline by lirping between the order-1 blending functions

As discussed, we get functions that start at 0, ramp up to 1 and back down, then stay at

zero Each function is 0 most of the time

So each blending function is defined in pieces Each piece is a polynomial of degree 1

(graph is a line)

So an order-2 B-spline is just the control polygon

Again, any number of control points may be used

We form an order-3 B-Spline by lirping between the order-2 blending functions

Now blending functions are smooth They start at 0, curve up to 1 then back down

Again, each function is 0 most of the time

Again, each blending function is defined in pieces Each piece is a polynomial of

degree 2

We continue this repeated-lirping procedure to define B-splines of higher order

See the blue book for details and graphs

Types of B-Splines Approximation Curves Used

B-Spline approximations can be classified based on the spacing of the knot vector and the use of weights

1 Uniform/Periodic B-splines : The spacing is

unform and the knots (control points) are equispaced e.g

[0,1,2,3,4,5] These have satisfactory smoothness but lack local control and the starting and ending poits are ill defined as above

2 Non-periodic: The knots are repeated at the ends m

times and the interior is equispaced e.g [0 0 0 1 2 3 3 3 ] These can be used to force the control point to start and finish at a control point

3 Non-uniform B-Splines : The spacing is

non-uniform and or repeated knots e.g [0 1 1 2 4 5 6 6

] These can be used to obtain local control

B-Splines

Ví dụ: Uniform Cubic B-spline on

[0,1]

Four control points are required to define the curve for 0t<1 (t is the

parameter)

Not surprising for a cubic curve with 4 degrees of freedom

The equation looks just like a Bezier curve, but with different basis functions

Also called blending functions - they describe how to blend the control points to

make the curve

( ) ( ) ( ) ( )3

3 3 2 2 3 2 1 3 2 0

3

0 4

61 3 3 3 1 3 6 4

61 3 3

P

t

B

t

P

i i

+

− + + + +

− +

− +

=

=∑= )

Basis Functions on [0,1]

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

t

Does the curve interpolate its endpoints?

Does it lie inside its convex hull?

B 0,4

B 3,4

( )3 3

3 2 2

3 2 1 1

3 2 0

6 1

3 3 3 1 6 1

3 6 4 6 1

3 3 1 6 1

t P

t t t P

t t P

t t t P t P

+

− + + +

+

− +

− +

= )

Uniform Cubic B-spline on [0,1)

The blending functions sum to one, and are positive everywhere

The curve lies inside its convex hull

The curve does not interpolate its endpoints

Requires hacks or non-uniform B-splines

There is also a matrix form for the curve:

=

1 0 0 0 1

1 3 3 3

4 0 6

3 1 3 3 1 6

3

3 2 1

t t P

P P P t

P )

Uniform - B-spline

Ni,k(u) đa thức B-Spline cơ bản Với n+ 1 sô điểm kiểm soát

Pi điểm kiểm soát thứ i

k bậc của đường cong 1<k<n+2

Ui vector nút của đường cong U=[U1,U2 Un+k+1]

i n

i i k

P u N u

=

=

).

( )

(

) ( ) (

) ( ) ( ) (

)

2 1

1 1

, 1 1

1

U U u U u N U U U u u

k i i

i k

i k i i k i k

− +

+

− +

=

 ∈

others 0

] , [ 1 )

1 ,

i i i

u u u u N

Ngày đăng: 09/03/2021, 06:25

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN