Skip to content

Commit 7af39ae

Browse files
committed
add docstring and use explicit variable names
1 parent eaa635d commit 7af39ae

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

skyfield/toposlib.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .functions import (
88
_T, angular_velocity_matrix, dots, length_of, mxm, mxv, rot_y, rot_z,
99
)
10-
from .positionlib import ICRF, Geocentric
10+
from .positionlib import Geocentric
1111
from .descriptorlib import reify
1212
from .units import Angle, Distance, _ltude
1313
from .vectorlib import VectorFunction
@@ -277,18 +277,20 @@ def _compute_latitude(self, position):
277277

278278
subpoint = geographic_position_of # deprecated method name
279279

280-
def intersection_of(self, vector):
280+
def intersection_of(self, icrf_vector):
281281
"""Return the surface point intersected by a vector.
282282
283-
TODO ...
284-
Returns a `GeographicPosition` giving the geodetic ``latitude`` and
285-
``longitude`` at the point that the ray intersects the surface of the
286-
Earth.
287-
283+
This method calculates the point at which the input `icrf_vector`
284+
intersects the surface of the Geoid. The input `icrf_vector` should be
285+
an :class:`~skyfield.positionlib.ICRF` object (or subclass thereof)
286+
and is implicitly assumed to extend to infinity.
288287
The main calculation implemented here is based on JPL's NAIF toolkit;
289288
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/ellipses.html
289+
290+
Returns a `GeographicPosition` with the geodetic ``latitude`` and
291+
``longitude`` at the point of intersection.
290292
"""
291-
if vector.t is None:
293+
if icrf_vector.t is None:
292294
raise ValueError(
293295
'you can only calculate an intersection for a vector that is'
294296
' defined at a fixed point in time (must have a non-null `.t`)'
@@ -303,9 +305,9 @@ def intersection_of(self, vector):
303305
inv_d_matrix = array([[a, 0.0, 0.0], [0.0, a, 0.0], [0.0, 0.0, c]])
304306

305307
# Apply distortion matrix to the vector
306-
position_xyz = vector.center.xyz.au
308+
position_xyz = icrf_vector.center.xyz.au
307309
d_position_xyz = mxv(d_matrix, position_xyz)
308-
d_direction = mxv(d_matrix, vector.target)
310+
d_direction = mxv(d_matrix, icrf_vector.target)
309311
# Rescale the vector to unit length
310312
d_direction = d_direction / length_of(d_direction)
311313

@@ -327,7 +329,7 @@ def intersection_of(self, vector):
327329

328330
# Apply inverse distortion and convert back to geocentric coords
329331
intersection = Geocentric(
330-
mxv(inv_d_matrix, d_intersection), t=vector.t
332+
mxv(inv_d_matrix, d_intersection), t=icrf_vector.t
331333
)
332334

333335
# Retrieve latitude and longitude

0 commit comments

Comments
 (0)