0% found this document useful (0 votes)
52 views

Expt 2 Code Only

This document discusses using MATLAB to calculate the angle between polar curves and the radius of curvature of polar curves at given points. It includes: 1) Code to calculate the angle between two polar curves r=4(1+cos(t)) and r=5(1-cos(t)) at their intersection point. 2) Code to calculate the angle between r=4cos(t) and r=5sin(t) by plotting the curves and finding their intersection point. 3) Code to calculate the radius of curvature of r=4(1+cos(t)) at t=π/2. 4) Code to calculate the radius of curvature of r=asin(

Uploaded by

srinidhi
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)
52 views

Expt 2 Code Only

This document discusses using MATLAB to calculate the angle between polar curves and the radius of curvature of polar curves at given points. It includes: 1) Code to calculate the angle between two polar curves r=4(1+cos(t)) and r=5(1-cos(t)) at their intersection point. 2) Code to calculate the angle between r=4cos(t) and r=5sin(t) by plotting the curves and finding their intersection point. 3) Code to calculate the radius of curvature of r=4(1+cos(t)) at t=π/2. 4) Code to calculate the radius of curvature of r=asin(

Uploaded by

srinidhi
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/ 4

Expt.

2 Angle between polar curves curvature and radius curvature


1. Angle between curves
2. Radius of curvature

Functions used

• subs() ; Symbolic substitution


• ezplot(); Easy-to-use function plotter
• simplify(); Algebraic simplification
• atan(); Tan inverse
• vpa(); Variable-precision arithmetic
• solve(); Equations and systems solver

2.0 Appetizer
The function solve() will provide a general solution for symbolic equations. Let us start with roots of quadratic
equations. We shall provide a quadratic equation to matlab and it generates a symbolic values to the roots of
the equation.

Quadratic equations run this code

syms a b c x s
eqn = a*x^2 + b*x + c == 0
s=solve(eqn)

We see it produces symbolic solution to quadratic equation. We can use solve() to generate symbolic
solution. Once the equation is generated, we can pass the values to the equation to get the exact value. We
use subs() to assign the variables to the equation. As shown here

subs(s,[a,b,c],[1,-7,12]) % pass 1,-7,12 for a,b,c for the equation

%%

We can solve the quadratic equations directly too

syms x
roots=solve(x^2 -7*x + 12,x)

2.1 Angle between curves

1
Angle between radius vector and tangent is given by tan φ = r dθ/dr .

If tan φ1 and tan φ2 are angle between radius vector and tangent of two curves then |φ1 − φ2| is the angle
between two curves at the point of intersection.

2.1.1 Find the angle between the curves: r = 4*(1 + cos(t)) and r = 5*(1 − cos(t)).

syms r t %define symbols r and t


r1 = 4 * ( 1 + cos ( t ) ) ; % Input first polar curve
r2 = 5 * ( 1 - cos ( t ) ) ;
dr1 = diff ( r1 , t ) % find the derivative of the function
dr2 = diff ( r2 , t )
t1 = r1 / dr1 % estimate r/{d(r1)/dt}
t2 = r2 / dr2
q = solve ( r1 == r2 , t ) %solve for r1 == r2 ,
% to find the point of intersection between curves
w1=subs(t1,vpa(q(2))); % Evaluate t1 with the value of q(2)
w2=subs(t2,vpa(q(2))); % q(2) has the value at point of intersection
y1 = atan ( w1 ); % find the inverse tan of w1
y2 = atan ( w2 );
w=abs(y1-y2); % diffrence between w1 and w2
fprintf('angle between curves is: %f',w) % display the result

%%

2.1.2 Find the angle between the curves r = 4*cos(t) and r = 5*sin(t)

This program uses ezplot(). Students are encouraged to change it to fplot()

syms r t
r1 = 4 * ( cos ( t ) ) ; % Define two curves
r2 = 5 * ( sin ( t ) ) ;
ezplot(r1)
hold on; ezplot(r2) % plot both the curves
dr1 = diff ( r1 , t ) %differntiate both the curves
dr2 = diff ( r2 , t )
figure() % plot the differentiated curves on a sperate window
ezplot(dr1)
hold on; ezplot(dr2)
t1 = r1 / dr1 % as in the previous example
t2 = r2 / dr2
q = solve ( r1 - r2 , t )
w1=subs(t1,vpa(q(1)));
w2=subs(t2,vpa(q(1)));
y1 = atan ( w1 ); % to find the inverse tan of w1
y2 = atan ( w2 );
w=abs(y1-y2) % you can use printf to print the result

2
2.2 Radius of curvature
Formula to calculate Radius of curvature in polar form is

2.2.1 To find the radius of curvature

r = 4(1 + cos (t)) at t=π/2

syms r t % define symbols r and t


r = 4 * ( 1 + cos ( t ) ); %define thet function
r1 = diff(r,t) % get the first derivative
r2= diff(r1,t) % get the second derivative
rho = (( r^2 + r1^2 )^(3/2)) / ( r^2 + (2 * r1^2) - (r * r2) ) %calculate rho
% expression for rho is given above
rho1 = subs(rho,t,pi/2) ; % estimate rho at pi/2

% convert symbolic varialbe to a number and print it on the screen


fprintf('radius of curvature is %f',vpa(rho1))

2.2.2 Find radius of curvature of r = a*sin(nt) at t = pi/2 and n = 1

syms t r a n
r = a * sin ( n * t ) ;
r1 = diff(r,t) ;
r2= diff(r1,t)
rho = (( r^2 + r1^2 )^(1.5))/ ( r^2 + 2 * r1^2 - r * r2 )
rho1 = subs(rho,t,pi/2)
rho2 = subs(rho1,n,1)
vpa(rho2)

3 Parametric curves
To find the radius of curvature equation is

With ' corresponding to first order and '' as second order differentiation

2.3.1 Find radius curvature of x = a*cos(t), y = a*sin(t) at r=5 and t = pi/2

syms t a x y %Define variables


y = a * sin ( t ) ; %define y as a sine value
x = a * cos ( t ) ; % define x as a cosine value

3
% perform algebraic simplification of the differentited functions
dydx = simplify(diff(y,t))/ simplify(diff(x,t) ) ;
rho = simplify((1 + dydx^2 )^(1.5)/(diff(dydx,t)/(diff(x,t)))) ;
display('radius of curvature:') ; vpa(rho)
% convert symbolic variable to a value using vpa() and display the same
t1 = pi / 2 ; % t=pi/2, as per the given expression
r1 = 5 ; % r= 5, as per the given expression

% Estimate radius of curvarute at 5,pi/2


rho1 = subs(rho,t,t1)
rho2 = subs(rho1,a,r1)

fprintf('Radius of curvature at r=%f and t=pi/2 is %f' ,r1, vpa(rho2))


% display the radius of curvature
curve = 1/rho2 ;
fprintf('Curvature at (%f , pi/2 ) is %f', r1, vpa(curve))

Write a code to estimate radius of curvature of y=a*sin(t)^(3/2) ; x = a*cos(t)^(3/2)

[email protected]

You might also like