0% found this document useful (0 votes)
79 views4 pages

Cse 90

The document contains code snippets using the Sympy library in Python to calculate properties like radius of curvature for parametric curves. It defines curves parametrically using trigonometric functions like sine and cosine, takes derivatives to find velocities and accelerations, and uses these to calculate the radius of curvature formula. Examples are worked out numerically by substituting specific parameter values.

Uploaded by

Sharan maga
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)
79 views4 pages

Cse 90

The document contains code snippets using the Sympy library in Python to calculate properties like radius of curvature for parametric curves. It defines curves parametrically using trigonometric functions like sine and cosine, takes derivatives to find velocities and accelerations, and uses these to calculate the radius of curvature formula. Examples are worked out numerically by substituting specific parameter values.

Uploaded by

Sharan maga
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

2/28/23, 12:45 PM sahran90 - Jupyter Notebook

In [1]: # sharan 90 cse-b


from sympy import *

r,t=symbols('r,t')

r1=4*(1+cos(t));
r2=5*(1-cos(t));
dr1=diff(r1,t)
dr2=diff(r2,t)
t1=r1/dr1
t2=r2/dr2
q=solve(r1-r2,t)

w1=t1.subs({t:float(q[1])})
w2=t2.subs({t:float(q[1])})
y1=atan(w1)
y2=atan(w2)
w=abs(y1-y2)
print('Angle between curves in radians is %0.3f'%(w))

Angle between curves in radians is 1.571

In [2]: from sympy import *



r,t=symbols('r,t')

r1=4*(cos(t));
r2=5*(sin(t));

dr1=diff(r1,t)
dr2=diff(r2,t)
t1=r1/dr1
t2=r2/dr2

q=solve(r1-r2,t)
w1=t1.subs({t:float(q[0])})
w2=t2.subs({t:float(q[0])})

y1=atan(w1)
y2=atan(w2)
w=abs(y1-y2)
print('Angle between curves in radians is %0.4f'%float(w))

Angle between curves in radians is 1.5708

localhost:8888/notebooks/sahran90.ipynb 1/4
2/28/23, 12:45 PM sahran90 - Jupyter Notebook

In [5]: #radius of curvature


from sympy import *
t=Symbol('t')
r=Symbol('r')
r=4*(1+cos(t))
r1=Derivative(r,t).doit()
r2=Derivative(r1,t).doit()
rho=(r**2+r1**2)**1.5/(r**2+2*r1**2-r*r2);
rho1=rho.subs(t,pi/2)
print('The radius of curvature is %3.4f units'%rho1)

The radius of curvature is 3.7712 units

In [6]: from sympy import *


t,r,a,n=symbols('t r a n')
r=a*sin(n*t)
r1=Derivative(r,t).doit()
r2=Derivative(r1,t).doit()
rho=(r**2+r1**2)**1.5/(r**2+2*r1**2-r*r2);
rho1=rho.subs(t,pi/2)
rho1=rho1.subs(n,1)
print("The radius of curvature is")
display(simplify(rho1))

The radius of curvature is

(𝑎2 )1.5
2𝑎2

localhost:8888/notebooks/sahran90.ipynb 2/4
2/28/23, 12:45 PM sahran90 - Jupyter Notebook

In [12]: from sympy import *


from sympy.abc import rho, x,y,r,K,t,a,b,c,alpha

y=(sqrt(x)-4)**2
y=a*sin(t)
x=a*cos(t)
dydx=simplify(Derivative(y,t).doit())/simplify(Derivative(x,t).doit())
rho=simplify((1+dydx**2)**1.5/(Derivative(dydx,t).doit()/(Derivative(x,t).doit()))

print('Radius of curvature is')
display(ratsimp(rho))
t1=pi/2
r1=5
rho1=rho.subs(t,t1);
rho2=rho1.subs(a,r1);
print('\n\nRadius of curvature at r=5 and t=pi/2 is',simplify(rho2));
curvature=1/rho2;
print('\n\nCurvature at(5,pi/2) is',float(curvature))

Radius of curvature is

1 0.5
−𝑎( sin2 (𝑡) ) sin(𝑡)

Radius of curvature at r=5 and t=pi/2 is -5

Curvature at(5,pi/2) is -0.2

localhost:8888/notebooks/sahran90.ipynb 3/4
2/28/23, 12:45 PM sahran90 - Jupyter Notebook

In [14]: from sympy import *


from sympy.abc import rho, x,y,r,K,t,a,b,c,alpha
y=(a*sin(t))**(3/2)
x=(a*cos(t))**(3/2)
dydx=simplify(Derivative(y,t).doit())/simplify(Derivative(x,t).doit())
rho=simplify((1+dydx**2)**1.5/(Derivative(dydx,t).doit()/(Derivative(x,t).doit()))
print('Radius of curvature is')
display(ratsimp(rho))
t1=pi/4
r1=1;
rho1=rho.subs(t,t1);
rho2=rho1.subs(a,r1);
display('Radius of curvature at r=1 and t=pi/4 is',simplify(rho2))
curvature=1/rho2;
print('\n\nCurvature at (1,pi/4) is ',float(curvature))

Radius of curvature is

3.0(𝑎cos(𝑡))3.0 ( (𝑎 cos(𝑎 (𝑡))sin3.0(𝑡))tan3.0 4 (𝑡) + 1)1.5 sin2 (𝑡) tan2 (𝑡)


− (𝑎sin(𝑡))1.5
'Radius of curvature at r=1 and t=pi/4 is'

−2.52268924576114
Curvature at (1,pi/4) is -0.39640237166757364

In [ ]: ​

localhost:8888/notebooks/sahran90.ipynb 4/4

You might also like