# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

from sympy import *
alpha1, K, L, gv, ga, a = symbols("alpha_1 K L g_a g_v a")
init_printing()

# +
a1 = pi / 2 + K * (L / 2 - alpha1)

r1 = (1 / K + ga * cos(gv * a1)) * cos(a1)
r2 = (1 / K + ga * cos(gv * a1)) * sin(a1)

dr1 = diff(r1, alpha1)
dr2 = diff(r2, alpha1)

n1 = -dr2 / sqrt(dr1**2 + dr2**2)
n2 = dr1 / sqrt(dr1**2 + dr2**2)

dn1 = sympify('K**2*g_a*g_v*(-K*g_a*g_v*sin(g_a*(K*(L/2 - alpha_1) + pi/2))*cos(K*(L/2 - alpha_1)) - K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*sin(K*(L/2 - alpha_1)))*(K*g_a**2*g_v*sin(g_a*(K*L - 2*K*alpha_1 + pi))/2 - K*g_v*sin(g_a*(K*L - 2*K*alpha_1 + pi))/2 - sin(g_a*(K*L/2 - K*alpha_1 + pi/2)))/((-K*g_a*g_v*sin(K*(L/2 - alpha_1))*sin(g_a*(K*(L/2 - alpha_1) + pi/2)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*cos(K*(L/2 - alpha_1)))**2 + (K*g_a*g_v*sin(g_a*(K*(L/2 - alpha_1) + pi/2))*cos(K*(L/2 - alpha_1)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*sin(K*(L/2 - alpha_1)))**2)**(3/2) + (K**2*g_a**2*g_v*cos(K*(L/2 - alpha_1))*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) - 2*K**2*g_a*g_v*sin(K*(L/2 - alpha_1))*sin(g_a*(K*(L/2 - alpha_1) + pi/2)) + K**2*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*cos(K*(L/2 - alpha_1)))/sqrt((-K*g_a*g_v*sin(K*(L/2 - alpha_1))*sin(g_a*(K*(L/2 - alpha_1) + pi/2)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*cos(K*(L/2 - alpha_1)))**2 + (K*g_a*g_v*sin(g_a*(K*(L/2 - alpha_1) + pi/2))*cos(K*(L/2 - alpha_1)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*sin(K*(L/2 - alpha_1)))**2)')
dn2 = sympify('K**2*g_a*g_v*(-K*g_a*g_v*sin(K*(L/2 - alpha_1))*sin(g_a*(K*(L/2 - alpha_1) + pi/2)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*cos(K*(L/2 - alpha_1)))*(K*g_a**2*g_v*sin(g_a*(K*L - 2*K*alpha_1 + pi))/2 - K*g_v*sin(g_a*(K*L - 2*K*alpha_1 + pi))/2 - sin(g_a*(K*L/2 - K*alpha_1 + pi/2)))/((-K*g_a*g_v*sin(K*(L/2 - alpha_1))*sin(g_a*(K*(L/2 - alpha_1) + pi/2)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*cos(K*(L/2 - alpha_1)))**2 + (K*g_a*g_v*sin(g_a*(K*(L/2 - alpha_1) + pi/2))*cos(K*(L/2 - alpha_1)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*sin(K*(L/2 - alpha_1)))**2)**(3/2) + (K**2*g_a**2*g_v*sin(K*(L/2 - alpha_1))*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 2*K**2*g_a*g_v*sin(g_a*(K*(L/2 - alpha_1) + pi/2))*cos(K*(L/2 - alpha_1)) + K**2*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*sin(K*(L/2 - alpha_1)))/sqrt((-K*g_a*g_v*sin(K*(L/2 - alpha_1))*sin(g_a*(K*(L/2 - alpha_1) + pi/2)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*cos(K*(L/2 - alpha_1)))**2 + (K*g_a*g_v*sin(g_a*(K*(L/2 - alpha_1) + pi/2))*cos(K*(L/2 - alpha_1)) + K*(g_v*cos(g_a*(K*(L/2 - alpha_1) + pi/2)) + 1/K)*sin(K*(L/2 - alpha_1)))**2)')

dn1 = dn1.subs(K*(L/2 - alpha1) + pi/2, a1)
dn2 = dn2.subs(K*(L/2 - alpha1) + pi/2, a1)

dn1
# -

dn1

r1

r2

dn1

dn2

# %matplotlib inline
# %run main3.py

StarcoderdataJupyterScriptsDedupFiltered