# Rotational transformation to ship fixed.

# Purpose
Wind and waves are given in world coordinates, how to transform them to ship fixed?

# Methodology
Using scipy to do the rotational transformation

# Setup


```python
# %load imports.py
from typing import no_type_check
%matplotlib inline
%load_ext autoreload
%autoreload 2

import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import sympy as sp


```

    The autoreload extension is already loaded. To reload it, use:
      %reload_ext autoreload



```python
from scipy.spatial.transform import Rotation as R
```

## Example usage


```python
psi = np.linspace(0,360,100)
r = R.from_euler('z', psi, degrees=True)
coords = r.apply([1,0,0])

fig,ax = plt.subplots()
ax.plot(coords[:,0], coords[:,1],'-');
ax.axis('equal');

r2 = r.inv()
coords = r2.apply(coords)

fig,ax = plt.subplots()
ax.plot(coords[:,0], coords[:,1],'o');
ax.set_xlim(-1,1)
ax.set_ylim(-1,1)
```


```python
from sympy.vector import CoordSys3D
W = CoordSys3D(name='W')
psi = sp.symbols('psi')
B = W.orient_new_axis('B', psi, W.k)
W.rotation_matrix(B)
```




$\displaystyle \left[\begin{matrix}\cos{\left(\psi \right)} & - \sin{\left(\psi \right)} & 0\\\sin{\left(\psi \right)} & \cos{\left(\psi \right)} & 0\\0 & 0 & 1\end{matrix}\right]$




```python

```

e6d8e4d1e0949c5744298da794085eaa80b117fd
ipynb
Jupyter Notebook
notebooks/01.1_transformation.ipynb
martinlarsalbert/ship_power_prediction
f34c57f31454dd0b45ad063b5520b9ccc6898562
MIT
notebooks/01.1_transformation.ipynb
martinlarsalbert/ship_power_prediction
f34c57f31454dd0b45ad063b5520b9ccc6898562
MIT
notebooks/01.1_transformation.ipynb
martinlarsalbert/ship_power_prediction
f34c57f31454dd0b45ad063b5520b9ccc6898562
MIT
Qwen/Qwen-72B
1. YES
2. YES