0% found this document useful (0 votes)
2 views5 pages

Assignment2 Solution

The document contains solutions to an assignment on computer-integrated manufacturing, focusing on parametric cubic splines and Bezier curves. It includes derivations of equations, matrix representations, and MATLAB code for plotting Bezier curves based on given control points. Additionally, it discusses the effects of changing control point order and positions on the resulting curves, as well as conditions for continuity between Bezier segments.

Uploaded by

Aniket Adsule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Assignment2 Solution

The document contains solutions to an assignment on computer-integrated manufacturing, focusing on parametric cubic splines and Bezier curves. It includes derivations of equations, matrix representations, and MATLAB code for plotting Bezier curves based on given control points. Additionally, it discusses the effects of changing control point order and positions on the resulting curves, as well as conditions for continuity between Bezier segments.

Uploaded by

Aniket Adsule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ME 714 Computer-integrated Manufacturing (1)

Assignment 2 Solution

Topics: Parametric Cubic Spline, Bezier Curves


Note: Please show all the important steps while answering the questions.

1. Determine the equation of the parametric cubic spline passing through points A and B, [4]
A = (2,5), Slope vector at A is at 900 w.r.t. the X-axis and has magnitude = 1,
B = (6,0), Slope vector at B is at 450 w.r.t. the X-axis and has magnitude = 1.
What is the slope of this curve at t = 0.5

  
2 −2 1 1 2 5
  
h i −3 3 −2 −1  6 0 
P (t) = [t][MH ][GH ] = t3 t2
  
t 1   
0
 0 1 0  cos(900 ) sin(900 )
 

1 0 0 0 cos(450 ) sin(450 )
 
−7.29 11.71
 
h i  11.29 −17.71
P (t) = t3 t2 t 1 
 

 0 1 
 
2 5
 
−7.29 11.71
 
h i  11.29 −17.71
P 0 (t) = 3t2
 
2t 1 0  0

 1 

2 5
P 0 (0.5) = [5.82, −7.93]

dy
Slope at point P is dx
= −7.93/5.82 = −1.36

2. Matrix representation of the parametric cubic spline is given as follows, [3]


  
2 −2 1 1 P (0)
  
h i −3 3 −2 −1  P (1) 
P (t) = [t][MH ][GH ] = t3 t2 (1)
  
t 1   
0 0
 0 1 0  P (0)
 

1 0 0 0 P 0 (1)

Soham Mujumdar ME 714 CIM(1) Assignment 2 Page 1 of 5


where, [MH ] is the Hermite matrix and [GH ] is geometric coefficient matrix. Derive a similar
matrix representation for the Bezier curve (i.e., B(t) = [t][MB ][V ]) given four control points
(V0 , V1 , V2 , V3 ).
n = 3 here. n  
X n
B(t) = (1 − t)n−i ti Vi 0≤t≤1
i=0
i

3  
X 3
B(t) = (1 − t)n−i ti Vi = (1 − t)3 V0 + 3(1 − t)2 tV1 + 3(1 − t)t2 V2 + t3 V3
i=0
i

Rearrange the terms to get,

  
−1 3 −3 1 V0
  
h i  3 −6 3 0 V 
  1
B(t) = [t][MB ][V ] = t3 t2

t 1 −3 3
 
 0 0  V 
  2
1 0 0 0 V3

3. Write a function in MATLAB or Python to plot the Bezier curve given control points (V0 , V1 , V2 , V3 ). [10]
The input to the function will be a four by two matrix [V],
 
Xv 0 Yv 0
 
X Y 
 v1 v1 
[V ] =   (2)
X
 v2 Yv2 

Xv3 Yv3

where, Xvi and Yvi are the x- and y-coordinates of the control point Vi . Upload your code as a
text file named ’LastName-FirstName-Bezier.txt’ (e.g., Mujumdar-Soham-Bezier.txt) in the as-
signment 2 section on the Moodle. (Note: Make sure your code is well-commented. Use atleast
100 points on the curve to plot the curve.)

clc ; clear all ; close all ;


%% MATLAB s c r i p t t o p l o t t h e B e z i e r c u r v e s w i t h g i v e n p o i n t s
% First
V = [0 ,0; 3 ,4; 5 ,2; 6 ,0];
p = p l o t B (V ) ;
% Second
V = [6 ,0; 5 ,2; 3 ,4; 0 ,0];

Soham Mujumdar ME 714 CIM(1) Assignment 2 Page 2 of 5


p = p l o t B (V ) ;
% Third
V = [0 ,0; 5 ,2; 3 ,4; 6 ,0];
p = p l o t B (V ) ;
% Fourth
V = [ 0 , 0 ; 3 , 4 ; 5 , −2; 6 , 0 ] ;
p = p l o t B (V ) ;

%% MATLAB f u n c t i o n t h a t p l o t s a c u b i c B e z i e r c u r v e g i v e n 4 c o n t r o l p o i n t s
f u n c t i o n p = p l o t B (V)
% I n p u t V i s i n a form o f 4 x 2 m a t r i x .
% Given f o u r c o n t r o l p o i n t s V0 , V1 , V2 , V3 ; V m a t r i x i s a s f o l l o w s :
% Row i f i r s t column i s x−c o o r d o f Vi−1
% Row i s e c o n d column i s y−c o o r d o f Vi−1
% e . g . V = [0 ,0; 3 ,4; 5 ,2; 6 ,0]
MB = [−1 3 −3 1 ; 3 −6 3 0 ; −3 3 0 0 ; 1 0 0 0 ] ; % Bezier curve matrix
% B ( t ) = [ T ] [MB] [ V ] ; l e t ’ s c a l c u l a t e MBV = [MB] [ V] f i r s t .
MBV = MB∗V;
% F o r o b t a i n i n g 101 p o i n t s a l o n g t h e c u r v e , we d i v i d e t h e r a n g e [ 0 , 1 ] i n
% 101 u n i f o r m i n t e r v a l s
t = linspace (0 ,1 ,101) ’;
T = [ t . ˆ 3 t . ˆ 2 t ones ( s i z e ( t ) ) ] ;
x = T∗MBV( : , 1 ) ; % x−c o o r d o f p o i n t s on t h e c u r v e
y = T∗MBV( : , 2 ) ; % y−c o o r d o f p o i n t s on t h e c u r v e
% Plot the curve
figure (); clf ;
p = p l o t ( x , y , ’ − r ’ , ’ l i n e w i d t h ’ , 2 ) ; h o l d on ;
p t s = p l o t (V ( : , 1 ) , V( : , 2 ) , ’ − − ok ’ , ’ M a r k e r F a c e C o l o r ’ , ’ k ’ ) ; % Showing c o n t r o l
g r i d on ;
xlim ( [ 0 , 6 ] ) ; ylim ( [ − 2 , 4] ) ;
x l a b e l ( ’X ’ ) ; y l a b e l ( ’Y ’ ) ;
% Plot settings
axis equal ;
s e t ( gca , ’ F o n t S i z e ’ , 1 0 ) ;
s e t ( gca , . . .
’ Box ’ , ’ on ’ , ...
’ TickDir ’ , ’ in ’ , ...

Soham Mujumdar ME 714 CIM(1) Assignment 2 Page 3 of 5


’ TickLength ’ , [.02 .02] , ...
’ YMinorTick ’ , ’ on ’ , ...
’ XMinorTick ’ , ’ on ’ , ...
’ XScale ’ , ’ linear ’ , ...
’ YScale ’ , ’ linear ’ , ...
’ LineWidth ’ , 0.2 );
end

4. Use your code from Q. 3 to plot the Bezier curves for each of the following sets of control points, [8]

• V0 = (0, 0), V1 = (3, 4), V2 = (5, 2), V3 = (6, 0)


• V0 = (6, 0), V1 = (5, 2), V2 = (3, 4), V3 = (0, 0)
• V0 = (0, 0), V1 = (5, 2), V2 = (3, 4), V3 = (6, 0)
• V0 = (0, 0), V1 = (3, 4), V2 = (5, −2), V3 = (6, 0)

Based on the plots, comment on what happens to the curve when (a) the order of the control points
is changed, and (b) one of the control points is moved.
The Bezier curve plots are shown in Fig. 1. From the the figure we can conclude that (a) changing
the order of the control points changes the Bezier curve except when the order is exactly reversed.
In that case, the curve remains same (even though the parametrization changes, i.e., which point
on the curve you get at a particular t = t0 ), and (b) moving the control point changes the Bezier
curve. The curve passes through first and the last control points, while the intermediate control
points pull the curve towards them giving it a particular shape.

5. Find (x,y,z) if the two Bezier curve segments (B1 and B2 ) passing through following sets of [5]
control points are required to be C 1 continuous at the common point D.

• B1 : A = (2, 3, 4), B = (3, 1, 5), C = (x, y, z), D = (3, 4, 3)


• B2 : D = (3, 4, 3), E = (2, 6, 0), F = (5, 7, 5), G = (5, 2, 3)

For the curve segments B1 , B2 to be C 1 continuous at the common point D, we must have (a)
value of B1 at D = value of B2 at D, and (b) slope of B1 at D = slope of B2 at D. Since (a) is
automatically satisfied due to the properties of Bezier curves, we only need to satisfy (b).
For a cubic Bezier curve, we have
3  
X 3
B(t) = (1 − t)n−i ti Vi = (1 − t)3 V0 + 3(1 − t)2 tV1 + 3(1 − t)t2 V2 + t3 V3
i=0
i

B 0 (t) = 3(1 − t)2 (V1 − V0 ) + 6(1 − t)t(V2 − V1 ) + 3t2 (V3 − V2 )

Soham Mujumdar ME 714 CIM(1) Assignment 2 Page 4 of 5


we need
B10 (t = 1) = B20 (t = 0)

3(D − C) = 3(E − D)

C = 2D − E = (4, 2, 6)

(a) (b)

(c) (d)

Figure 1: Bezier curves

Soham Mujumdar ME 714 CIM(1) Assignment 2 Page 5 of 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy