```python
from math import pi
import numpy as np
import sympy as sy
from sympy.utilities.lambdify import lambdify
```


```python
import matplotlib.pyplot as plt
```


```python
phi = sy.Symbol("phi")
_lambda = sy.Symbol("Lambda")
delta = sy.Symbol("delta")

R_x = sy.rot_axis1(phi).T
R_z = sy.rot_axis3(-_lambda).T
R_y = sy.rot_axis2(delta).T
```


```python
vector = sy.Matrix([0,1,0])

final_vector = R_y * R_z * R_x * vector

planform_vector = sy.Matrix(final_vector)
planform_vector[-1] = 0
```


```python
print(sy.latex(planform_vector, mul_symbol="\cdot"))
```

    \left[\begin{matrix}\sin{\left(\Lambda \right)}\cdot\cos{\left(\delta \right)}\cdot\cos{\left(\phi \right)} + \sin{\left(\delta \right)}\cdot\sin{\left(\phi \right)}\\\cos{\left(\Lambda \right)}\cdot\cos{\left(\phi \right)}\\0\end{matrix}\right]



```python
planform_vector
```




$\displaystyle \left[\begin{matrix}\sin{\left(\Lambda \right)} \cos{\left(\delta \right)} \cos{\left(\phi \right)} + \sin{\left(\delta \right)} \sin{\left(\phi \right)}\\\cos{\left(\Lambda \right)} \cos{\left(\phi \right)}\\0\end{matrix}\right]$




```python
sy.simplify((final_vector.T * u_planform_vector)[0])
```




$\displaystyle \frac{\left(\sin{\left(\Lambda \right)} \cos{\left(\delta \right)} \cos{\left(\phi \right)} + \sin{\left(\delta \right)} \sin{\left(\phi \right)}\right) \left(\sin{\left(\phi \right)} + \cos{\left(\Lambda \right)} \cos{\left(\phi \right)}\right) \sin{\left(\Lambda \right)} + \cos^{2}{\left(\Lambda \right)} \cos^{2}{\left(\phi \right)}}{\cos{\left(\phi \right)}}$




```python
sy.simplify((planform_vector.T / sy.cos(phi) * final_vector)[0])
```




$\displaystyle \frac{\left(\sin{\left(\Lambda \right)} \cos{\left(\delta \right)} \cos{\left(\phi \right)} + \sin{\left(\delta \right)} \sin{\left(\phi \right)}\right)^{2}}{\cos{\left(\phi \right)}} + \cos^{2}{\left(\Lambda \right)} \cos{\left(\phi \right)}$




```python
print(sy.python(final_vector, ))
```

    Lambda = Symbol('Lambda')
    delta = Symbol('delta')
    phi = Symbol('phi')
    e = MutableDenseMatrix([[sin(Lambda)*cos(delta)*cos(phi) + sin(delta)*sin(phi)], [cos(Lambda)*cos(phi)], [-sin(Lambda)*sin(delta)*cos(phi) + sin(phi)*cos(delta)]])



```python
final_vector
```




$\displaystyle \left[\begin{matrix}\sin{\left(\Lambda \right)} \cos{\left(\delta \right)} \cos{\left(\phi \right)} + \sin{\left(\delta \right)} \sin{\left(\phi \right)}\\\cos{\left(\Lambda \right)} \cos{\left(\phi \right)}\\- \sin{\left(\Lambda \right)} \sin{\left(\delta \right)} \cos{\left(\phi \right)} + \sin{\left(\phi \right)} \cos{\left(\delta \right)}\end{matrix}\right]$




```python
sy.simplify(final_vector.subs(delta, 0)[-1] / final_vector.subs(delta, 0)[0])
```




$\displaystyle \frac{\tan{\left(\phi \right)}}{\sin{\left(\Lambda \right)}}$




```python
sy.tan(pi/2)
```




$\displaystyle 1.63312393531954 \cdot 10^{16}$




```python
final_vector[0]
```




$\displaystyle \sin{\left(\Lambda \right)} \cos{\left(\delta \right)} \cos{\left(\phi \right)} + \sin{\left(\delta \right)} \sin{\left(\phi \right)}$




```python
numerical_vector = lambdify((phi, _lambda, delta), final_vector)
```


```python
fig = plt.figure(figsize=(10,10))
axes = fig.add_subplot(111, projection='3d')

vec = numerical_vector(pi/3, pi/10, pi/10)

# Winglet LE
axes.plot([0, vec[0]], [0, vec[1]], [0, vec[2]], lw = 2.0)

# Plot projections
options_proj = dict(lw = 1.0, linestyle = '--')

axes.plot([0, vec[0]], [0, vec[1]], [0, 0], **options_proj)
axes.plot([0, 0], [0, vec[1]], [0, vec[2]], **options_proj)
axes.plot([0, vec[0]], [1, 1], [0, vec[2]], **options_proj)

axes.set_xlabel("x")
axes.set_ylabel("y")
axes.set_zlabel("z")

axes.set_xlim(xmin = 0.0, xmax = 1.0)
axes.set_ylim(ymin = 0.0, ymax = 1.0)
axes.set_zlim(zmin = 0.0, zmax = 1.0)
axes.set_title("Winglet LE and projections")
```


```python
print(sy.latex(vector))
```

    \left[\begin{matrix}0\\1\\0\end{matrix}\right]



```python
fig = plt.figure(figsize=(10,10))
axes = fig.add_subplot(121, projection='3d')

vec_1 = numerical_vector(pi/4, pi/4)
vec_2 = numerical_vector(pi/4, pi/3)

# Winglet LE
axes.plot([0, vec_1[0]], [0, vec_1[1]], [0, vec_1[2]], lw = 2.0, c = 'b')
axes.plot([0, vec_2[0]], [0, vec_2[1]], [0, vec_2[2]], lw = 2.0, c="r")

# Plot projections
options_proj = dict(lw = 1.0, linestyle = '--')

# Out of plane projection
axes.plot([0,0], [0, vec_1[1]], [0, vec_1[2]], **options_proj, c = 'b')
axes.plot([0,0], [0, vec_2[1]], [0, vec_2[2]], **options_proj, c = "r")

# In plane projection
axes.plot([0, vec_1[0]], [0, vec_1[1]], [0,0], **options_proj, c = 'b')
axes.plot([0, vec_2[0]], [0, vec_2[1]], [0,0], **options_proj, c = "r")

axes.set_xlabel("x")
axes.set_ylabel("y")
axes.set_zlabel("z")

axes.set_xlim(xmin = 0.0, xmax = 1.0)
axes.set_ylim(ymin = 0.0, ymax = 1.0)
axes.set_zlim(zmin = 0.0, zmax = 1.0)
axes.set_title("Sweep angle influence in the zy-projection")


axes = fig.add_subplot(122, projection='3d')
vec_1 = numerical_vector(pi/4, pi/4)
vec_2 = numerical_vector(pi/3, pi/4)

# Winglet LE
axes.plot([0, vec_1[0]], [0, vec_1[1]], [0, vec_1[2]], lw = 2.0, c = 'b')
axes.plot([0, vec_2[0]], [0, vec_2[1]], [0, vec_2[2]], lw = 2.0, c="r")

# Plot projections
options_proj = dict(lw = 1.0, linestyle = '--')

# Out of plane projection
axes.plot([0,0], [0, vec_1[1]], [0, vec_1[2]], **options_proj, c = 'b')
axes.plot([0,0], [0, vec_2[1]], [0, vec_2[2]], **options_proj, c = "r")

# In plane projection
axes.plot([0, vec_1[0]], [0, vec_1[1]], [0,0], **options_proj, c = 'b')
axes.plot([0, vec_2[0]], [0, vec_2[1]], [0,0], **options_proj, c = "r")

axes.set_xlabel("x")
axes.set_ylabel("y")
axes.set_zlabel("z")

axes.set_xlim(xmin = 0.0, xmax = 1.0)
axes.set_ylim(ymin = 0.0, ymax = 1.0)
axes.set_zlim(zmin = 0.0, zmax = 1.0)
axes.set_title("Cant angle influence in the xy-projection")

plt.savefig("sweep_cant_angle_projections.png", dpi = 300, bbox_inches="tight", transparent=True)
```

ba8d1eeffba12e831b5f61bf72b8ec8ca34a9dd7
ipynb
Jupyter Notebook
notebooks/Winglet geometry (sympy).ipynb
KikeM/winglets
4db90737d5d8007c65a738134e22d7db34a7587c
MIT
2020-03-16T22:53:58.000Z
2021-11-10T16:49:30.000Z
notebooks/Winglet geometry (sympy).ipynb
KikeM/winglets
4db90737d5d8007c65a738134e22d7db34a7587c
MIT
2020-04-21T01:25:23.000Z
2021-01-08T20:19:27.000Z
notebooks/Winglet geometry (sympy).ipynb
KikeM/winglets
4db90737d5d8007c65a738134e22d7db34a7587c
MIT
Qwen/Qwen-72B
1. YES
2. YES