Open reza-ghazi opened 1 week ago
@reza-ghazi — The formulae in precessionlib.py
do not compute the precession of the ecliptic, as seems to be the case in the table you have shared, but the precession of the equator. The numbers Skyfield uses are the official numbers from IAU 2000 from this paper:
https://www.aanda.org/articles/aa/full/2003/48/aa4068/aa4068.html
Look in particular at formulae 37 and 39 from that paper, and I think you will see that they agree exactly with Skyfield's code.
It is interesting that you mention the comment — it used to say:
# R3(chi_a) R1(-omega_a) R3(-psi_a) R1(epsilon_0).
But then a contributor complained that the rotation matrices in the comment were all backwards. Here is the issue they opened:
https://github.com/skyfielders/python-skyfield/issues/972
And so the comment got changed, because when I did a quick test, it did indeed look like rotation matrices worked in the direction that they claimed — was I wrong in letting them convince me, and I should not have made the change? If you can point out where that contributor made a mistake, I will be happy to reverse the change and return the comment to its original form! That way, Skyfield would again agree with the NOVAS library that the logic was adapted from, which has exactly the same comment.
@brandon-rhodes - I've read the #972; I think the following explanation makes it clear:
The definitions of the rotation matrices depend on the direction of rotation (clockwise vs. counterclockwise) and the convention (e.g., physics vs. mathematics vs. computer graphics). The definitions from Wikipedia and my earlier explanation are correct but represent different conventions.
$$ R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \ 0 & \cos\theta & -\sin\theta \ 0 & \sin\theta & \cos\theta \end{bmatrix} $$
$$ R_y(\theta) = \begin{bmatrix} \cos\theta & 0 & \sin\theta \ 0 & 1 & 0 \ -\sin\theta & 0 & \cos\theta \end{bmatrix} $$
$$ R_z(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta & 0 \ \sin\theta & \cos\theta & 0 \ 0 & 0 & 1 \end{bmatrix} $$
$$ R_x(\phi) = \begin{bmatrix} 1 & 0 & 0 \ 0 & \cos\phi & \sin\phi \ 0 & -\sin\phi & \cos\phi \end{bmatrix} $$
$$ R_y(\phi) = \begin{bmatrix} \cos\phi & 0 & -\sin\phi \ 0 & 1 & 0 \ \sin\phi & 0 & \cos\phi \end{bmatrix} $$
$$ R_z(\phi) = \begin{bmatrix} \cos\phi & \sin\phi & 0 \ -\sin\phi & \cos\phi & 0 \ 0 & 0 & 1 \end{bmatrix} $$
Wikipedia uses a clockwise rotation convention when viewed along the positive axis ( e.g., positive $z$-axis for $R_z(\theta)$ ).
My earlier explanation follows the counterclockwise rotation convention when viewed along the positive axis.
$$ R{\text{Wikipedia}}(\theta) = R{\text{My Definition}}(-\phi) $$
The choice depends on our application:
If we want to convert from one to the other:
$$ R{\text{My Definition}}(\phi) = R{\text{Wikipedia}}(-\phi) $$
For your information, I checked the resource [^1] of The ESAA and found that your values for $\psi_A$ and $\omega_A$ are correct; strangely, they have made a mistake in producing the same table in ESAA.
I also checked the Expressions for IAU 2000 precession quantities again, and I found that the matrix multiplication is precisely the same as I mentioned.
[^1]: Hilton, J. L., N. Capitaine, J. Chapront, J. M. Ferrandiz, A. Fienga, T. Fukushima, J. Getino, P. Mathews, J.-L. Simon, M. Soffel, J. Vondrak, P. Wallace, and J. Williams (2006). Report of the International Astronomical Union Division I Working Group on Precession and the Ecliptic. Celestial Mechanics and Dynamical Astronomy 94, 351-367.
Hello,
There are some mistakes in the
precessionlib.py
$\psi_A$ and $\omega_A$ series terms. I attached the picture shot from the table on (ESAA[^1], page 216), highlighting the correct numbers that should be replaced with the current values in the file.On the other hand, the Precession matrix is defined as:
$$ \mathbf{P}=\mathbf{R}_3\left(\chi_A\right) \mathbf{R}_1\left(-\omega_A\right) \mathbf{R}_3\left(-\psi_A\right) \mathbf{R}_1\left(\varepsilon_0\right) \rightarrow \text{(ESAA, page 220)} $$
But you have mentioned in the docstring that "R3(-chi_a) R1(omega_a) R3(psi_a) R1(-epsilon_0)"
Let me explain more here:
The equations describe the two precession matrices:
$\mathbf{P} = \mathbf{R}_3(\chi_A) \mathbf{R}_1(-\omega_A) \mathbf{R}_3(-\psi_A) \mathbf{R}_1(\varepsilon_0)$
$\mathbf{P} = \mathbf{R}_3(-\chi_A) \mathbf{R}_1(\omega_A) \mathbf{R}_3(\psi_A) \mathbf{R}_1(-\varepsilon_0)$
They are not the same, but they are closely related. Their relationship depends on the reference frames and the direction of transformation being considered.
Key Differences
Transformation Direction:
Rotational Signs:
Inverse Transformation:
$$ \mathbf{P}_2 = \mathbf{P}_1^{-1} $$
Mathematical Relationship
The relationship between the two matrices is:
$$ \mathbf{P}_2 = \mathbf{P}_1^{-1} $$
Where:
The inverse of a rotation matrix is equivalent to its transpose when the matrix is orthonormal (as all rotation matrices are):
$$ \mathbf{P}_1^{-1} = \mathbf{P}_1^T $$
Thus, the two matrices are inversely related, meaning applying one matrix followed by the other will return the original coordinates:
$$ \mathbf{P}_2 \mathbf{P}_1 = \mathbf{I} $$
Physical Interpretation
$$ \mathbf{r} = \mathbf{P}_1 \mathbf{r}_0 $$
$$ \mathbf{r}_0 = \mathbf{P}_2 \mathbf{r} $$
Conclusion
$$ \mathbf{P}_2 = \mathbf{P}_1^{-1} $$
[^1]: Urban, S. E., & Seidelmann, P. K. (2013). Explanatory Supplement to the Astronomical Almanac (3rd ed.). University Science Books. ISBN: 978-1-891389-85-6.
Thank you,