Showing posts with label MAV11. Show all posts
Showing posts with label MAV11. Show all posts

Friday, October 20, 2023

i) Angle between radius vector and tangent vector ii) Angle of intersection between two polar curves

i) Angle between radius vector and tangent vector

Algorithm:

·       For a given curve $$r=f(\theta)$$, find $$\phi=cot^-1(\frac{r'}{r})$$, where $$r'=dr/d\theta$$

clear

clc

close

syms theta

%Get the curve

r1=input("Enter the first curve r1(theta): r1=");

%Find phi1

phi1=simplify(acot(diff(r1)/r1));

%display phi1

fprintf("\n Angle between radius vector and tangent vector to the curve %s:\n phi= %s",r1,phi1)

 

Output

Enter the first curve r1(theta): r1=2*(1+cos(theta))

Angle between radius vector and tangent vector to the curve 2*cos(theta) + 2:

 phi1= -acot(sin(theta)/(cos(theta) + 1))

 

ii) Angle of intersection between two polar curves

Algorithm:

·      For a given curve $$r_1=f_1(\theta)$$ and $$r_2=f_2(\theta)$$ find, $$\phi=cot^{-1}(\frac{r'}{r})$$

 where $$r'=dr/d\theta$$

·       Solve given curves for theta value

·       Get the required appropriate theta value from the solution

·       Find $$|\phi_2-\phi_1|$$ by substituting obtained  theta value

clear

clc

close

syms theta

 

%Get the two curves

r1=input("Enter the first curve r1(theta): r1=");

r2=input("Enter the second curve r2(theta): r2=");

%Find phi1 and phi2

 

phi1=simplify(acot(diff(r1)/r1));

phi2=simplify(acot(diff(r2)/r2));

 

%display phi1 and phi2

fprintf("\n Angle between radius vector and tangent vector to the curve %s:\n phi1= %s",r1,phi1)

fprintf("\n Angle between radius vector and tangent vector to the curve %s:\n phi2= %s",r2,phi2)

 

%Find t(point of intersection)

fprintf('\n The values of theta at the point of intersection are: ')

S=solve(r1==r2,theta,'Real',true)

 

%Get the theta

tt=input("\n Choose the value of theta: ");

 

%Calculate the angle between the given curves

ang1= abs(vpa(subs(phi1-phi2, {theta},{tt})));

ang2=vpa(pi-ang1);

fprintf('\n Angle between given polar curves = %f or %f \n', ang1, ang2);

Output

Enter the first curve r1(theta): r1=2*(1+cos(theta))

Enter the second curve r2(theta): r2=2*(1-cos(theta))

Angle between radius vector and tangent vector to the curve 2*cos(theta) + 2:

phi1= -acot(sin(theta)/(cos(theta) + 1))

Angle between radius vector and tangent vector to the curve 2 - 2*cos(theta):

phi2= -acot(sin(theta)/(cos(theta) - 1))

The values of theta at the point of intersection are: S =

pi/2

Choose the value of theta: pi/2

Angle between given polar curves = 1.570796 or 1.570796

 


Plotting Curves

Plotting XY Data

Syntax

plot(X,Y, 'options')

creates a 2-D line plot of the data in Y versus the corresponding values in X, where X and Y are vectors of the same length.

Plotting function

fplot(f,xinterval)

plots expression or function f over the specified interval. Specify the interval as a two-element vector of the form [xmin xmax].

If we did not mention xinterval, fplot plots the function f over the default interval [-5 5] for x

Example

Plot the functions   $$y1=50cos(x)sin(x),\\y2=4x^3-4x+14,\\y3=10x$$ in the range [-2,2]. 

Using plot

clc

clear

close

 

x = [-2:0.01:2];

%Define the functions to plot

y1 = 50*cos(x).*sin(x);

y2 = 4*x.^3-4*x+14;

y3 = 10*x;

 

plot(x,y1,'b','linewidth',1)

hold on

plot(x,y2,'--r','linewidth',1)

plot(x,y3,'-.m','linewidth',1.5)

hold off

%Customization (Optional)

xlabel('\bf x-Axis'); ylabel('\bf y-Axis')

title('\fontname{Arial} Cartesian Plot','fontsize',14)

 

legend('y1','y2','y3')

 

Output

 


Using plot

clc

clear

close

syms x

y1 = 50*cos(x)*sin(x);

y2 = 4*x^3-4*x+14;

y3 = 10*x

 

fplot([y1,y2,y3],[-2,2])

 

%Customization (Optional)

xlabel('\bf x-Axis'); ylabel('\bf y-Axis')

title('Cartesian Plot','fontsize',14)

legend('y1','y2','y3')

 Output

Plotting Polar plot

 Syntax

polarplot(theta,rho)

plots a line in polar coordinates, with theta indicating the angle in radians and rho indicating the radius value for each point. The inputs must be vectors of equal length or matrices of equal size.

Example

Plot the graph of the polar curves $$r=cos(2\theta); r=sin(3\theta)$$

clc

clear

close all

t=linspace(0,2*pi);

r1=input("Enter the first polar curve r1=f(t): r1=");

r2=input("Enter the second polar curve r2=f(t): r2=");

polarplot(t,r1,'m',t,r2,'b','linewidth',2);

 Output




Search This Blog