Skip to content

Commit

Permalink
Write rotation matrices in random_directions docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
YagoMCastro committed Jun 27, 2024
1 parent b43ea30 commit 7ca7511
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ List of functions and classes (API)
:toctree: generated/

read_qdm_harvard
random_directions
3 changes: 2 additions & 1 deletion magali/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#
from ._input_output import random_unitary_vector, read_qdm_harvard
from ._input_output import read_qdm_harvard
from ._synthetic import random_directions
from ._version import __version__
21 changes: 20 additions & 1 deletion magali/_synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def random_directions(
inclination, declination, dispersion_angle, size, random_state=None
):
"""
r"""
Creates a random directions around a preferred direction.
Parameters
Expand Down Expand Up @@ -50,6 +50,25 @@ def random_directions(
- Generate random directions
- Rotation
>- R_z(phi)*R_y(theta)
.. math::
R_z(\phi)R_y(\theta) = \begin{bmatrix}
\cos(\theta) & 0 & \sin(\theta) \\
0 & 1 & 0 \\
-\sin(\theta) & 0 & \cos(\cos)
\end{bmatrix} \begin{bmatrix}
\cos(\phi) & -\sin(\phi) & 0 \\
\sin(\phi) & \cos(\phi) & 0 \\
0 & 0 & 1
\end{bmatrix} \begin{bmatrix}
x \\ y \\ z
\end{bmatrix} = \begin{bmatrix}
\cos(\phi)(X\cos(\theta)+Z\sin(\theta))-Y\sin(\phi) \\
\sin(\phi)(X\cos(\theta)+Z\sin(\theta))+Y\cos(\phi) \\
-X\sin(\theta)+Z\cos(\theta)
\end{bmatrix}
"""
alpha = np.deg2rad(np.random.uniform(0, 360, size))
r = np.random.normal(0, dispersion_angle, size)
Expand Down

0 comments on commit 7ca7511

Please sign in to comment.