Coverage for pygeodesy/cartesianBase.py: 92%
332 statements
« prev ^ index » next coverage.py v7.2.2, created at 2024-06-10 14:08 -0400
« prev ^ index » next coverage.py v7.2.2, created at 2024-06-10 14:08 -0400
2# -*- coding: utf-8 -*-
4u'''(INTERNAL) Private C{CartesianBase} class for elliposiodal, spherical and N-/vectorial
5C{Cartesian}s and public functions L{rtp2xyz}, L{rtp2xyz_}, L{xyz2rtp} and L{xyz2rtp_}.
7After I{(C) Chris Veness 2011-2015} published under the same MIT Licence**, see
8U{https://www.Movable-Type.co.UK/scripts/latlong.html},
9U{https://www.Movable-Type.co.UK/scripts/latlong-vectors.html} and
10U{https://www.Movable-Type.co.UK/scripts/geodesy/docs/latlon-ellipsoidal.js.html}.
11'''
13# from pygeodesy.basics import _xinstanceof # from .datums
14from pygeodesy.constants import EPS, EPS0, INT0, PI2, _isfinite, isnear0, \
15 _0_0, _1_0, _N_1_0, _2_0, _4_0, _6_0
16from pygeodesy.datums import Datum, _earth_ellipsoid, _spherical_datum, \
17 Transform, _WGS84, _xinstanceof
18# from pygeodesy.ecef import EcefKarney # _MODS
19from pygeodesy.errors import _IsnotError, _TypeError, _ValueError, _xattr, \
20 _xdatum, _xkwds, _xkwds_get, _xkwds_pop2
21from pygeodesy.fmath import cbrt, hypot, hypot_, hypot2, fabs, sqrt # hypot
22# from pygeodesy.formy import _hartzell # _MODS
23from pygeodesy.fsums import fsumf_, Fmt
24from pygeodesy.interns import _COMMASPACE_, _datum_, _no_, _phi_
25from pygeodesy.interns import _ellipsoidal_, _spherical_ # PYCHOK used!
26from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS
27from pygeodesy.named import _name2__, _Pass
28from pygeodesy.namedTuples import LatLon4Tuple, _NamedTupleTo , Vector3Tuple, \
29 Vector4Tuple, Bearing2Tuple # PYCHOK .sphericalBase
30# from pygeodesy.nvectorBase import _N_vector # _MODS
31from pygeodesy.props import deprecated_method, Property, Property_RO, \
32 property_doc_, property_RO, _update_all
33# from pygeodesy,resections import cassini, collins5, pierlot, pierlotx, \
34# tienstra7 # _MODS
35# from pygeodesy.streprs import Fmt # from .fsums
36# from pygeodesy.triaxials import Triaxial_ # _MODS
37from pygeodesy.units import Degrees, Height, _heigHt, _isMeter, Meter, Radians
38from pygeodesy.utily import acos1, sincos2d, sincos2_, atan2, degrees, radians
39from pygeodesy.vector3d import Vector3d, _xyzhdlln4
40# from pygeodesy.vector3dBase import _xyz3 # _MODS
41# from pygeodesy import ltp # _MODS
43# from math import atan2, degrees, fabs, radians, sqrt # from .fmath, .utily
45__all__ = _ALL_LAZY.cartesianBase
46__version__ = '24.06.10'
48_r_ = 'r'
49_theta_ = 'theta'
52class CartesianBase(Vector3d):
53 '''(INTERNAL) Base class for ellipsoidal and spherical C{Cartesian}.
54 '''
55 _datum = None # L{Datum}, to be overriden
56 _height = None # height (L{Height}), set or approximated
58 def __init__(self, x_xyz, y=None, z=None, datum=None, **ll_name):
59 '''New C{Cartesian...}.
61 @arg x_xyz: Cartesian X coordinate (C{scalar}) or a C{Cartesian},
62 L{Ecef9Tuple}, L{Vector3Tuple} or L{Vector4Tuple}.
63 @kwarg y: Cartesian Y coordinate (C{scalar}), ignored if B{C{x_xyz}}
64 is not C{scalar}, otherwise same units as B{C{x_xyz}}.
65 @kwarg z: Cartesian Z coordinate (C{scalar}), ignored if B{C{x_xyz}}
66 is not C{scalar}, otherwise same units as B{C{x_xyz}}.
67 @kwarg datum: Optional datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}
68 or L{a_f2Tuple}).
69 @kwarg ll_name: Optional C{B{name}=NN} (C{str}) and optional, original
70 latlon C{B{ll}=None} (C{LatLon}).
72 @raise TypeError: Non-scalar B{C{x_xyz}}, B{C{y}} or B{C{z}} coordinate
73 or B{C{x_xyz}} not a C{Cartesian}, L{Ecef9Tuple},
74 L{Vector3Tuple} or L{Vector4Tuple} or B{C{datum}} is
75 not a L{Datum}.
76 '''
77 h, d, ll, n = _xyzhdlln4(x_xyz, None, datum, **ll_name)
78 Vector3d.__init__(self, x_xyz, y=y, z=z, ll=ll, name=n)
79 if h is not None:
80 self._height = Height(h)
81 if d is not None:
82 self.datum = d
84# def __matmul__(self, other): # PYCHOK Python 3.5+
85# '''Return C{NotImplemented} for C{c_ = c @ datum} and C{c_ = c @ transform}.
86# '''
87# return NotImplemented if isinstance(other, (Datum, Transform)) else \
88# _NotImplemented(self, other)
90 def cassini(self, pointB, pointC, alpha, beta, useZ=False):
91 '''3-Point resection between this and 2 other points using U{Cassini
92 <https://NL.WikiPedia.org/wiki/Achterwaartse_insnijding>}'s method.
94 @arg pointB: Second point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
95 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
96 @arg pointC: Center point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
97 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
98 @arg alpha: Angle subtended by triangle side C{b} from B{C{pointA}} to
99 B{C{pointC}} (C{degrees}, non-negative).
100 @arg beta: Angle subtended by triangle side C{a} from B{C{pointB}} to
101 B{C{pointC}} (C{degrees}, non-negative).
102 @kwarg useZ: If C{True}, use and interpolate the Z component, otherwise
103 force C{z=INT0} (C{bool}).
105 @note: Typically, B{C{pointC}} is between this and B{C{pointB}}.
107 @return: The survey point, an instance of this (sub-)class.
109 @raise ResectionError: Near-coincident, -colinear or -concyclic points
110 or negative or invalid B{C{alpha}} or B{C{beta}}.
112 @raise TypeError: Invalid B{C{pointA}}, B{C{pointB}} or B{C{pointM}}.
114 @see: Function L{pygeodesy.cassini} for references and more details.
115 '''
116 return _MODS.resections.cassini(self, pointB, pointC, alpha, beta,
117 useZ=useZ, datum=self.datum)
119 @deprecated_method
120 def collins(self, pointB, pointC, alpha, beta, useZ=False):
121 '''DEPRECATED, use method L{collins5}.'''
122 return self.collins5(pointB, pointC, alpha, beta, useZ=useZ)
124 def collins5(self, pointB, pointC, alpha, beta, useZ=False):
125 '''3-Point resection between this and 2 other points using U{Collins<https://Dokumen.tips/
126 documents/three-point-resection-problem-introduction-kaestner-burkhardt-method.html>}' method.
128 @arg pointB: Second point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
129 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
130 @arg pointC: Center point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
131 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
132 @arg alpha: Angle subtended by triangle side C{b} from B{C{pointA}} to
133 B{C{pointC}} (C{degrees}, non-negative).
134 @arg beta: Angle subtended by triangle side C{a} from B{C{pointB}} to
135 B{C{pointC}} (C{degrees}, non-negative).
136 @kwarg useZ: If C{True}, use and interpolate the Z component, otherwise
137 force C{z=INT0} (C{bool}).
139 @note: Typically, B{C{pointC}} is between this and B{C{pointB}}.
141 @return: L{Collins5Tuple}C{(pointP, pointH, a, b, c)} with survey C{pointP},
142 auxiliary C{pointH}, each an instance of this (sub-)class and
143 triangle sides C{a}, C{b} and C{c}.
145 @raise ResectionError: Near-coincident, -colinear or -concyclic points
146 or negative or invalid B{C{alpha}} or B{C{beta}}.
148 @raise TypeError: Invalid B{C{pointB}} or B{C{pointM}}.
150 @see: Function L{pygeodesy.collins5} for references and more details.
151 '''
152 return _MODS.resections.collins5(self, pointB, pointC, alpha, beta,
153 useZ=useZ, datum=self.datum)
155 @deprecated_method
156 def convertDatum(self, datum2, **datum):
157 '''DEPRECATED, use method L{toDatum}.'''
158 return self.toDatum(datum2, **datum)
160 @property_doc_(''' this cartesian's datum (L{Datum}).''')
161 def datum(self):
162 '''Get this cartesian's datum (L{Datum}).
163 '''
164 return self._datum
166 @datum.setter # PYCHOK setter!
167 def datum(self, datum):
168 '''Set this cartesian's C{datum} I{without conversion}
169 (L{Datum}), ellipsoidal or spherical.
171 @raise TypeError: The B{C{datum}} is not a L{Datum}.
172 '''
173 d = _spherical_datum(datum, name=self.name)
174 if self._datum: # is not None
175 if d.isEllipsoidal and not self._datum.isEllipsoidal:
176 raise _IsnotError(_ellipsoidal_, datum=datum)
177 elif d.isSpherical and not self._datum.isSpherical:
178 raise _IsnotError(_spherical_, datum=datum)
179 if self._datum != d:
180 _update_all(self)
181 self._datum = d
183 def destinationXyz(self, delta, Cartesian=None, **name_Cartesian_kwds):
184 '''Calculate the destination using a I{local} delta from this cartesian.
186 @arg delta: Local delta to the destination (L{XyzLocal}, L{Enu}, L{Ned}
187 or L{Local9Tuple}).
188 @kwarg Cartesian: Optional (geocentric) class to return the destination
189 or C{None}.
190 @kwarg name_Cartesian_kwds: Optional C{B{name}=NN} (C{str}) and optional,
191 additional B{C{Cartesian}} keyword arguments, ignored if
192 C{B{Cartesian} is None}.
194 @return: Destination as a C{B{Cartesian}(x, y, z, **B{Cartesian_kwds})}
195 instance or if C{B{Cartesian} is None}, an L{Ecef9Tuple}C{(x, y,
196 z, lat, lon, height, C, M, datum)} with C{M=None} always.
198 @raise TypeError: Invalid B{C{delta}}, B{C{Cartesian}} or B{C{Cartesian_kwds}}
199 item or C{datum} missing or incompatible.
200 '''
201 n, kwds = _name2__(name_Cartesian_kwds, _or_nameof=self)
202 if Cartesian is None:
203 r = self._Ltp._local2ecef(delta, nine=True)
204 else:
205 d = self.datum
206 if not d:
207 raise _TypeError(delta=delta, txt=_no_(_datum_))
208 t = _xkwds_get(kwds, datum=d)
209 if _xattr(t, ellipsoid=None) != d.ellipsoid:
210 raise _TypeError(datum=t, txt=str(d))
211 c = self._Ltp._local2ecef(delta, nine=False)
212 r = Cartesian(*c, **kwds)
213 return r.renamed(n) if n else r
215 @property_RO
216 def Ecef(self):
217 '''Get the ECEF I{class} (L{EcefKarney}), I{once}.
218 '''
219 CartesianBase.Ecef = E = _MODS.ecef.EcefKarney # overwrite property_RO
220 return E
222 @Property_RO
223 def _ecef9(self):
224 '''(INTERNAL) Helper for L{toEcef}, L{toLocal} and L{toLtp} (L{Ecef9Tuple}).
225 '''
226 return self.Ecef(self.datum, name=self.name).reverse(self, M=True)
228 @property_RO
229 def ellipsoidalCartesian(self):
230 '''Get the C{Cartesian type} iff ellipsoidal, overloaded in L{CartesianEllipsoidalBase}.
231 '''
232 return False
234 def hartzell(self, los=False, earth=None):
235 '''Compute the intersection of a Line-Of-Sight from this cartesian Point-Of-View
236 (pov) and this cartesian's ellipsoid surface.
238 @kwarg los: Line-Of-Sight, I{direction} to the ellipsoid (L{Los}, L{Vector3d}),
239 C{True} for the I{normal, plumb} onto the surface or I{False} or
240 C{None} to point to the center of the ellipsoid.
241 @kwarg earth: The earth model (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple}
242 or C{scalar} radius in C{meter}), overriding this cartesian's
243 C{datum} ellipsoid.
245 @return: The intersection (C{Cartesian}) with C{.height} set to the distance to
246 this C{pov}.
248 @raise IntersectionError: Null or bad C{pov} or B{C{los}}, this C{pov} is inside
249 the ellipsoid or B{C{los}} points outside or away from
250 the ellipsoid.
252 @raise TypeError: Invalid B{C{los}} or invalid or undefined B{C{earth}} or C{datum}.
254 @see: Function L{hartzell<pygeodesy.formy.hartzell>} for further details.
255 '''
256 return _MODS.formy._hartzell(self, los, earth)
258 @Property
259 def height(self):
260 '''Get the height (C{meter}).
261 '''
262 return self._height4.h if self._height is None else self._height
264 @height.setter # PYCHOK setter!
265 def height(self, height):
266 '''Set the height (C{meter}).
268 @raise TypeError: Invalid B{C{height}} C{type}.
270 @raise ValueError: Invalid B{C{height}}.
271 '''
272 h = Height(height)
273 if self._height != h:
274 _update_all(self)
275 self._height = h
277 def _height2C(self, r, Cartesian=None, datum=None, height=INT0, **kwds):
278 '''(INTERNAL) Helper for methods C{.height3} and C{.height4}.
279 '''
280 if Cartesian is not None:
281 r = Cartesian(r, **kwds)
282 if datum is not None:
283 r.datum = datum
284 if height is not None:
285 r.height = height # Height(height)
286 return r
288 def height3(self, earth=None, height=None, **Cartesian_and_kwds):
289 '''Compute the cartesian at a height above or below this certesian's ellipsoid.
291 @kwarg earth: A datum, ellipsoid, triaxial ellipsoid or earth radius,
292 I{overriding} this cartesian's datum (L{Datum}, L{Ellipsoid},
293 L{Ellipsoid2}, L{a_f2Tuple} or C{meter}, conventionally).
294 @kwarg height: The height (C{meter}, conventionally), overriding this
295 cartesian's height.
296 @kwarg Cartesian_and_kwds: Optional C{B{Cartesian}=None} class to return
297 the cartesian I{at height} and additional B{C{Cartesian}}
298 keyword arguments.
300 @return: An instance of B{C{Cartesian}} or if C{B{Cartesian} is None},
301 a L{Vector3Tuple}C{(x, y, z)} with the C{x}, C{y} and C{z}
302 coordinates I{at height} in C{meter}, conventionally.
304 @note: This cartesian's coordinates are returned if B{C{earth}} and this
305 datum or B{C{heigth}} and/or this height are C{None} or undefined.
307 @note: Include keyword argument C{B{datum}=None} if class B{C{Cartesian}}
308 does not accept a B{C{datum}} keyword agument.
310 @raise TriaxialError: No convergence in triaxial root finding.
312 @raise TypeError: Invalid or undefined B{C{earth}} or C{datum}.
313 '''
314 n = self.height3.__name__
315 d = self.datum if earth is None else _spherical_datum(earth, name=n)
316 c, h = self, _heigHt(self, height)
317 if h and d:
318 R, r = self.Roc2(earth=d)
319 if R > EPS0:
320 R = (R + h) / R
321 r = ((r + h) / r) if r > EPS0 else _1_0
322 c = c.times_(R, R, r)
324 r = Vector3Tuple(c.x, c.y, c.z, name=n)
325 if Cartesian_and_kwds:
326 r = self._height2C(r, **_xkwds(Cartesian_and_kwds, datum=d))
327 return r
329 @Property_RO
330 def _height4(self):
331 '''(INTERNAL) Get this C{height4}-tuple.
332 '''
333 try:
334 r = self.datum.ellipsoid.height4(self, normal=True)
335 except (AttributeError, ValueError): # no datum, null cartesian,
336 r = Vector4Tuple(self.x, self.y, self.z, 0, name__=self.height4)
337 return r
339 def height4(self, earth=None, normal=True, **Cartesian_and_kwds):
340 '''Compute the projection of this point on and the height above or below
341 this datum's ellipsoid surface.
343 @kwarg earth: A datum, ellipsoid, triaxial ellipsoid or earth radius,
344 I{overriding} this datum (L{Datum}, L{Ellipsoid},
345 L{Ellipsoid2}, L{a_f2Tuple}, L{Triaxial}, L{Triaxial_},
346 L{JacobiConformal} or C{meter}, conventionally).
347 @kwarg normal: If C{True} the projection is the nearest point on the
348 ellipsoid's surface, otherwise the intersection of the
349 radial line to the ellipsoid's center and the surface.
350 @kwarg Cartesian_and_kwds: Optional C{B{Cartesian}=None} class to return
351 the I{projection} and additional B{C{Cartesian}} keyword
352 arguments.
354 @return: An instance of B{C{Cartesian}} or if C{B{Cartesian} is None}, a
355 L{Vector4Tuple}C{(x, y, z, h)} with the I{projection} C{x}, C{y}
356 and C{z} coordinates and height C{h} in C{meter}, conventionally.
358 @note: Include keyword argument C{B{datum}=None} if class B{C{Cartesian}}
359 does not accept a B{C{datum}} keyword agument.
361 @raise TriaxialError: No convergence in triaxial root finding.
363 @raise TypeError: Invalid or undefined B{C{earth}} or C{datum}.
365 @see: Methods L{Ellipsoid.height4} and L{Triaxial_.height4} for more information.
366 '''
367 n = self.height4.__name__
368 d = self.datum if earth is None else earth
369 if normal and d is self.datum:
370 r = self._height4
371 elif isinstance(d, _MODS.triaxials.Triaxial_):
372 r = d.height4(self, normal=normal)
373 try:
374 d = d.toEllipsoid(name=n)
375 except (TypeError, ValueError): # TriaxialError
376 d = None
377 else:
378 r = _earth_ellipsoid(d).height4(self, normal=normal)
380 if Cartesian_and_kwds:
381 if d and not isinstance(d, Datum):
382 d = _spherical_datum(d, name=n)
383 r = self._height2C(r, **_xkwds(Cartesian_and_kwds, datum=d))
384 return r
386 @Property_RO
387 def isEllipsoidal(self):
388 '''Check whether this cartesian is ellipsoidal (C{bool} or C{None} if unknown).
389 '''
390 return _xattr(self.datum, isEllipsoidal=None)
392 @Property_RO
393 def isSpherical(self):
394 '''Check whether this cartesian is spherical (C{bool} or C{None} if unknown).
395 '''
396 return _xattr(self.datum, isSpherical=None)
398 @Property_RO
399 def latlon(self):
400 '''Get this cartesian's (geodetic) lat- and longitude in C{degrees} (L{LatLon2Tuple}C{(lat, lon)}).
401 '''
402 return self.toEcef().latlon
404 @Property_RO
405 def latlonheight(self):
406 '''Get this cartesian's (geodetic) lat-, longitude in C{degrees} with height (L{LatLon3Tuple}C{(lat, lon, height)}).
407 '''
408 return self.toEcef().latlonheight
410 @Property_RO
411 def latlonheightdatum(self):
412 '''Get this cartesian's (geodetic) lat-, longitude in C{degrees} with height and datum (L{LatLon4Tuple}C{(lat, lon, height, datum)}).
413 '''
414 return self.toEcef().latlonheightdatum
416 @Property_RO
417 def _Ltp(self):
418 '''(INTERNAL) Cache for L{toLtp}.
419 '''
420 return _MODS.ltp.Ltp(self._ecef9, ecef=self.Ecef(self.datum), name=self.name)
422 @Property_RO
423 def _N_vector(self):
424 '''(INTERNAL) Get the (C{nvectorBase._N_vector_}).
425 '''
426 _N = _MODS.nvectorBase._N_vector_
427 x, y, z, h = self._n_xyzh4(self.datum)
428 return _N(x, y, z, h=h, name=self.name)
430 def _n_xyzh4(self, datum):
431 '''(INTERNAL) Get the n-vector components as L{Vector4Tuple}.
432 '''
433 def _ErrorEPS0(x):
434 return _ValueError(origin=self, txt=Fmt.PARENSPACED(EPS0=x))
436 _xinstanceof(Datum, datum=datum)
437 # <https://www.Movable-Type.co.UK/scripts/geodesy/docs/
438 # latlon-nvector-ellipsoidal.js.html#line309>,
439 # <https://GitHub.com/pbrod/nvector>/src/nvector/core.py>
440 # _equation23 and <https://www.NavLab.net/nvector>
441 E = datum.ellipsoid
442 x, y, z = self.xyz
444 # Kenneth Gade eqn 23
445 p = hypot2(x, y) * E.a2_
446 q = z**2 * E.e21 * E.a2_
447 r = fsumf_(p, q, -E.e4) / _6_0
448 s = (p * q * E.e4) / (_4_0 * r**3)
449 t = cbrt(fsumf_(_1_0, s, sqrt(s * (_2_0 + s))))
450 if isnear0(t):
451 raise _ErrorEPS0(t)
452 u = fsumf_(_1_0, t, _1_0 / t) * r
453 v = sqrt(u**2 + E.e4 * q)
454 t = v * _2_0
455 if t < EPS0: # isnear0
456 raise _ErrorEPS0(t)
457 w = fsumf_(u, v, -q) * E.e2 / t
458 k = sqrt(fsumf_(u, v, w**2)) - w
459 if isnear0(k):
460 raise _ErrorEPS0(k)
461 t = k + E.e2
462 if isnear0(t):
463 raise _ErrorEPS0(t)
464 e = k / t
465# d = e * hypot(x, y)
466# tmp = 1 / hypot(d, z) == 1 / hypot(e * hypot(x, y), z)
467 t = hypot_(x * e, y * e, z) # == 1 / tmp
468 if t < EPS0: # isnear0
469 raise _ErrorEPS0(t)
470 h = fsumf_(k, E.e2, _N_1_0) / k * t
471 s = e / t # == e * tmp
472 return Vector4Tuple(x * s, y * s, z / t, h, name=self.name)
474 @Property_RO
475 def philam(self):
476 '''Get this cartesian's (geodetic) lat- and longitude in C{radians} (L{PhiLam2Tuple}C{(phi, lam)}).
477 '''
478 return self.toEcef().philam
480 @Property_RO
481 def philamheight(self):
482 '''Get this cartesian's (geodetic) lat-, longitude in C{radians} with height (L{PhiLam3Tuple}C{(phi, lam, height)}).
483 '''
484 return self.toEcef().philamheight
486 @Property_RO
487 def philamheightdatum(self):
488 '''Get this cartesian's (geodetic) lat-, longitude in C{radians} with height and datum (L{PhiLam4Tuple}C{(phi, lam, height, datum)}).
489 '''
490 return self.toEcef().philamheightdatum
492 def pierlot(self, point2, point3, alpha12, alpha23, useZ=False, eps=EPS):
493 '''3-Point resection between this and two other points using U{Pierlot
494 <http://www.Telecom.ULg.ac.Be/triangulation>}'s method C{ToTal} with
495 I{approximate} limits for the (pseudo-)singularities.
497 @arg point2: Second point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
498 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
499 @arg point3: Third point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
500 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
501 @arg alpha12: Angle subtended from this point to B{C{point2}} or
502 B{C{alpha2 - alpha}} (C{degrees}).
503 @arg alpha23: Angle subtended from B{C{point2}} to B{C{point3}} or
504 B{C{alpha3 - alpha2}} (C{degrees}).
505 @kwarg useZ: If C{True}, interpolate the Z component, otherwise use C{z=INT0}
506 (C{bool}).
507 @kwarg eps: Tolerance for C{cot} (pseudo-)singularities (C{float}).
509 @note: This point, B{C{point2}} and B{C{point3}} are ordered counter-clockwise.
511 @return: The survey (or robot) point, an instance of this (sub-)class.
513 @raise ResectionError: Near-coincident, -colinear or -concyclic points
514 or invalid B{C{alpha12}} or B{C{alpha23}}.
516 @raise TypeError: Invalid B{C{point2}} or B{C{point3}}.
518 @see: Function L{pygeodesy.pierlot} for references and more details.
519 '''
520 return _MODS.resections.pierlot(self, point2, point3, alpha12, alpha23,
521 useZ=useZ, eps=eps, datum=self.datum)
523 def pierlotx(self, point2, point3, alpha1, alpha2, alpha3, useZ=False):
524 '''3-Point resection between this and two other points using U{Pierlot
525 <http://www.Telecom.ULg.ac.Be/publi/publications/pierlot/Pierlot2014ANewThree>}'s
526 method C{ToTal} with I{exact} limits for the (pseudo-)singularities.
528 @arg point2: Second point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
529 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
530 @arg point3: Third point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple},
531 C{Vector4Tuple} or C{Vector2Tuple} if C{B{useZ}=False}).
532 @arg alpha1: Angle at B{C{point1}} (C{degrees}).
533 @arg alpha2: Angle at B{C{point2}} (C{degrees}).
534 @arg alpha3: Angle at B{C{point3}} (C{degrees}).
535 @kwarg useZ: If C{True}, interpolate the survey point's Z component,
536 otherwise use C{z=INT0} (C{bool}).
538 @return: The survey (or robot) point, an instance of this (sub-)class.
540 @raise ResectionError: Near-coincident, -colinear or -concyclic points or
541 invalid B{C{alpha1}}, B{C{alpha2}} or B{C{alpha3}}.
543 @raise TypeError: Invalid B{C{point2}} or B{C{point3}}.
545 @see: Function L{pygeodesy.pierlotx} for references and more details.
546 '''
547 return _MODS.resections.pierlotx(self, point2, point3, alpha1, alpha2, alpha3,
548 useZ=useZ, datum=self.datum)
550 def Roc2(self, earth=None):
551 '''Compute this cartesian's I{normal} and I{pseudo, z-based} radius of curvature.
553 @kwarg earth: A datum, ellipsoid, triaxial ellipsoid or earth radius,
554 I{overriding} this cartesian's datum (L{Datum}, L{Ellipsoid},
555 L{Ellipsoid2}, L{a_f2Tuple} or C{meter}, conventionally).
557 @return: 2-Tuple C{(R, r)} with the I{normal} and I{pseudo, z-based} radius of
558 curvature C{R} respectively C{r}, both in C{meter} conventionally.
560 @raise TypeError: Invalid or undefined B{C{earth}} or C{datum}.
561 '''
562 r = z = fabs( self.z)
563 R, _0 = hypot(self.x, self.y), EPS0
564 if R < _0: # polar
565 R = z
566 elif z > _0: # non-equatorial
567 d = self.datum if earth is None else _spherical_datum(earth)
568 e = self.toLatLon(datum=d, height=0, LatLon=None) # Ecef9Tuple
569 M = e.M # EcefMatrix
570 sa, ca = map(fabs, (M._2_2_, M._2_1_) if M else sincos2d(e.lat))
571 if ca < _0: # polar
572 R = z
573 else: # prime-vertical, normal roc R
574 R = R / ca # /= chokes PyChecker
575 r = R if sa < _0 else (r / sa) # non-/equatorial
576 return R, r
578 @property_RO
579 def sphericalCartesian(self):
580 '''Get the C{Cartesian type} iff spherical, overloaded in L{CartesianSphericalBase}.
581 '''
582 return False
584 @deprecated_method
585 def tienstra(self, pointB, pointC, alpha, beta=None, gamma=None, useZ=False):
586 '''DEPRECATED, use method L{tienstra7}.'''
587 return self.tienstra7(pointB, pointC, alpha, beta=beta, gamma=gamma, useZ=useZ)
589 def tienstra7(self, pointB, pointC, alpha, beta=None, gamma=None, useZ=False):
590 '''3-Point resection between this and two other points using U{Tienstra
591 <https://WikiPedia.org/wiki/Tienstra_formula>}'s formula.
593 @arg pointB: Second point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple}, C{Vector4Tuple} or
594 C{Vector2Tuple} if C{B{useZ}=False}).
595 @arg pointC: Third point (C{Cartesian}, L{Vector3d}, C{Vector3Tuple}, C{Vector4Tuple} or
596 C{Vector2Tuple} if C{B{useZ}=False}).
597 @arg alpha: Angle subtended by triangle side C{a} from B{C{pointB}} to B{C{pointC}} (C{degrees},
598 non-negative).
599 @kwarg beta: Angle subtended by triangle side C{b} from this to B{C{pointC}} (C{degrees},
600 non-negative) or C{None} if C{B{gamma} is not None}.
601 @kwarg gamma: Angle subtended by triangle side C{c} from this to B{C{pointB}} (C{degrees},
602 non-negative) or C{None} if C{B{beta} is not None}.
603 @kwarg useZ: If C{True}, use and interpolate the Z component, otherwise force C{z=INT0}
604 (C{bool}).
606 @note: This point, B{C{pointB}} and B{C{pointC}} are ordered clockwise.
608 @return: L{Tienstra7Tuple}C{(pointP, A, B, C, a, b, c)} with survey C{pointP},
609 an instance of this (sub-)class and triangle angle C{A} at this point,
610 C{B} at B{C{pointB}} and C{C} at B{C{pointC}} in C{degrees} and
611 triangle sides C{a}, C{b} and C{c}.
613 @raise ResectionError: Near-coincident, -colinear or -concyclic points or sum of
614 B{C{alpha}}, B{C{beta}} and B{C{gamma}} not C{360} or
615 negative B{C{alpha}}, B{C{beta}} or B{C{gamma}}.
617 @raise TypeError: Invalid B{C{pointB}} or B{C{pointC}}.
619 @see: Function L{pygeodesy.tienstra7} for references and more details.
620 '''
621 return _MODS.resections.tienstra7(self, pointB, pointC, alpha, beta, gamma,
622 useZ=useZ, datum=self.datum)
624 @deprecated_method
625 def to2ab(self): # PYCHOK no cover
626 '''DEPRECATED, use property C{philam}.
628 @return: A L{PhiLam2Tuple}C{(phi, lam)}.
629 '''
630 return self.philam
632 @deprecated_method
633 def to2ll(self): # PYCHOK no cover
634 '''DEPRECATED, use property C{latlon}.
636 @return: A L{LatLon2Tuple}C{(lat, lon)}.
637 '''
638 return self.latlon
640 @deprecated_method
641 def to3llh(self, datum=None): # PYCHOK no cover
642 '''DEPRECATED, use property L{latlonheight} or L{latlonheightdatum}.
644 @return: A L{LatLon4Tuple}C{(lat, lon, height, datum)}.
646 @note: This method returns a B{C{-4Tuple}} I{and not a} C{-3Tuple}
647 as its name may suggest.
648 '''
649 t = self.toLatLon(datum=datum, LatLon=None)
650 return LatLon4Tuple(t.lat, t.lon, t.height, t.datum, name=self.name)
652# def _to3LLh(self, datum, LL, **pairs): # OBSOLETE
653# '''(INTERNAL) Helper for C{subclass.toLatLon} and C{.to3llh}.
654# '''
655# r = self.to3llh(datum) # LatLon3Tuple
656# if LL is not None:
657# r = LL(r.lat, r.lon, height=r.height, datum=datum, name=self.name)
658# for n, v in pairs.items():
659# setattr(r, n, v)
660# return r
662 def toDatum(self, datum2, datum=None):
663 '''Convert this cartesian from one datum to an other.
665 @arg datum2: Datum to convert I{to} (L{Datum}).
666 @kwarg datum: Datum to convert I{from} (L{Datum}).
668 @return: The converted point (C{Cartesian}).
670 @raise TypeError: B{C{datum2}} or B{C{datum}}
671 invalid.
672 '''
673 _xinstanceof(Datum, datum2=datum2)
675 c = self if datum in (None, self.datum) else \
676 self.toDatum(datum)
678 i, d = False, c.datum
679 if d == datum2:
680 return c.copy() if c is self else c
682 elif d is None or (d.transform.isunity and
683 datum2.transform.isunity):
684 return c.dup(datum=datum2)
686 elif d == _WGS84:
687 d = datum2 # convert from WGS84 to datum2
689 elif datum2 == _WGS84:
690 i = True # convert to WGS84 by inverse transformation
692 else: # neither datum2 nor c.datum is WGS84, invert to WGS84 first
693 c = c.toTransform(d.transform, inverse=True, datum=_WGS84)
694 d = datum2
696 return c.toTransform(d.transform, inverse=i, datum=datum2)
698 def toEcef(self):
699 '''Convert this cartesian to I{geodetic} (lat-/longitude) coordinates.
701 @return: An L{Ecef9Tuple}C{(x, y, z, lat, lon, height,
702 C, M, datum)} with C{C} and C{M} if available.
704 @raise EcefError: A C{.datum} or an ECEF issue.
705 '''
706 return self._ecef9
708 def toLatLon(self, datum=None, height=None, LatLon=None, **LatLon_kwds): # see .ecef.Ecef9Tuple.toDatum
709 '''Convert this cartesian to a I{geodetic} (lat-/longitude) point.
711 @kwarg datum: Optional datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}
712 or L{a_f2Tuple}).
713 @kwarg height: Optional height, overriding the converted height
714 (C{meter}), iff B{C{LatLon}} is not C{None}.
715 @kwarg LatLon: Optional class to return the geodetic point
716 (C{LatLon}) or C{None}.
717 @kwarg LatLon_kwds: Optional, additional B{C{LatLon}} keyword
718 arguments, ignored if C{B{LatLon} is None}.
720 @return: The geodetic point (B{C{LatLon}}) or if B{C{LatLon}}
721 is C{None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon,
722 height, C, M, datum)} with C{C} and C{M} if available.
724 @raise TypeError: Invalid B{C{datum}} or B{C{LatLon_kwds}}.
725 '''
726 d = _spherical_datum(datum or self.datum, name=self.name)
727 if d == self.datum:
728 r = self.toEcef()
729 else:
730 c = self.toDatum(d)
731 r = c.Ecef(d, name=self.name).reverse(c, M=LatLon is None)
733 if LatLon: # class or .classof
734 h = _heigHt(r, height)
735 r = LatLon(r.lat, r.lon, datum=r.datum, height=h,
736 **_xkwds(LatLon_kwds, name=r.name))
737 _xdatum(r.datum, d)
738 return r
740 def toLocal(self, Xyz=None, ltp=None, **Xyz_kwds):
741 '''Convert this I{geocentric} cartesian to I{local} C{X}, C{Y} and C{Z}.
743 @kwarg Xyz: Optional class to return C{X}, C{Y} and C{Z} (L{XyzLocal},
744 L{Enu}, L{Ned}) or C{None}.
745 @kwarg ltp: The I{local tangent plane} (LTP) to use, overriding this
746 cartesian's LTP (L{Ltp}).
747 @kwarg Xyz_kwds: Optional, additional B{C{Xyz}} keyword arguments,
748 ignored if C{B{Xyz} is None}.
750 @return: An B{C{Xyz}} instance or a L{Local9Tuple}C{(x, y, z, lat, lon,
751 height, ltp, ecef, M)} if C{B{Xyz} is None} (with C{M=None}).
753 @raise TypeError: Invalid B{C{ltp}}.
754 '''
755 return _MODS.ltp._toLocal(self, ltp, Xyz, Xyz_kwds) # self._ecef9
757 def toLtp(self, Ecef=None, **name):
758 '''Return the I{local tangent plane} (LTP) for this cartesian.
760 @kwarg Ecef: Optional ECEF I{class} (L{EcefKarney}, ...
761 L{EcefYou}), overriding this cartesian's C{Ecef}.
762 @kwarg name: Optional C{B{name}=NN} (C{str}).
763 '''
764 return _MODS.ltp._toLtp(self, Ecef, self._ecef9, name) # self._Ltp
766 def toNvector(self, Nvector=None, datum=None, **name_Nvector_kwds):
767 '''Convert this cartesian to C{n-vector} components, I{including height}.
769 @kwarg Nvector: Optional class to return the C{n-vector} components
770 (C{Nvector}) or C{None}.
771 @kwarg datum: Optional datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}
772 or L{a_f2Tuple}) overriding this cartesian's datum.
773 @kwarg name_Nvector_kwds: Optional C{B{name}=NN} (C{str}) and optional,
774 additional B{C{Nvector}} keyword arguments, ignored if
775 C{B{Nvector} is None}.
777 @return: An B{C{Nvector}} or a L{Vector4Tuple}C{(x, y, z, h)} if
778 B{C{Nvector}} is C{None}.
780 @raise TypeError: Invalid B{C{Nvector}}, B{C{datum}} or
781 B{C{name_Nvector_kwds}} item.
783 @raise ValueError: B{C{Cartesian}} at origin.
784 '''
785 r, d = self._N_vector.xyzh, self.datum
786 if datum is not None:
787 d = _spherical_datum(datum, name=self.name)
788 if d != self.datum:
789 r = self._n_xyzh4(d)
791 if Nvector is None:
792 n, _ = _name2__(name_Nvector_kwds, _or_nameof=self)
793 if n:
794 r = r.dup(name=n)
795 else:
796 kwds = _xkwds(name_Nvector_kwds, h=r.h, datum=d)
797 r = Nvector(r.x, r.y, r.z, **self._name1__(kwds))
798 return r
800 def toRtp(self):
801 '''Convert this cartesian to I{spherical, polar} coordinates.
803 @return: L{RadiusThetaPhi3Tuple}C{(r, theta, phi)} with C{theta}
804 and C{phi}, both in L{Degrees}.
806 @see: Function L{xyz2rtp_} and class L{RadiusThetaPhi3Tuple}.
807 '''
808 return _rtp3(self.toRtp, Degrees, self, name=self.name)
810 def toStr(self, prec=3, fmt=Fmt.SQUARE, sep=_COMMASPACE_): # PYCHOK expected
811 '''Return the string representation of this cartesian.
813 @kwarg prec: Number of (decimal) digits, unstripped (C{int}).
814 @kwarg fmt: Enclosing backets format (C{letter}).
815 @kwarg sep: Separator to join (C{str}).
817 @return: Cartesian represented as "[x, y, z]" (C{str}).
818 '''
819 return Vector3d.toStr(self, prec=prec, fmt=fmt, sep=sep)
821 def toTransform(self, transform, inverse=False, datum=None):
822 '''Apply a Helmert transform to this cartesian.
824 @arg transform: Transform to apply (L{Transform} or L{TransformXform}).
825 @kwarg inverse: Apply the inverse of the C{B{transform}} (C{bool}).
826 @kwarg datum: Datum for the transformed cartesian (L{Datum}), overriding
827 this cartesian's datum but I{not} taken it into account.
829 @return: A transformed cartesian (C{Cartesian}) or a copy of this
830 cartesian if C{B{transform}.isunity}.
832 @raise TypeError: Invalid B{C{transform}}.
833 '''
834 _xinstanceof(Transform, transform=transform)
835 if transform.isunity:
836 c = self.dup(datum=datum or self.datum)
837 else:
838 # if inverse and d != _WGS84:
839 # raise _ValueError(inverse=inverse, datum=d,
840 # txt_not_=_WGS84.name)
841 xyz = transform.transform(*self.xyz, inverse=inverse)
842 c = self.dup(xyz=xyz, datum=datum or self.datum)
843 return c
845 def toVector(self, Vector=None, **Vector_kwds):
846 '''Return this cartesian's I{geocentric} components as vector.
848 @kwarg Vector: Optional class to return the I{geocentric}
849 components (L{Vector3d}) or C{None}.
850 @kwarg Vector_kwds: Optional, additional B{C{Vector}} keyword
851 arguments, ignored if C{B{Vector} is None}.
853 @return: A B{C{Vector}} or a L{Vector3Tuple}C{(x, y, z)} if
854 B{C{Vector}} is C{None}.
856 @raise TypeError: Invalid B{C{Vector}} or B{C{Vector_kwds}}.
857 '''
858 return self.xyz if Vector is None else Vector(
859 self.x, self.y, self.z, **self._name1__(Vector_kwds))
862class RadiusThetaPhi3Tuple(_NamedTupleTo):
863 '''3-Tuple C{(r, theta, phi)} with radial distance C{r} in C{meter}, inclination
864 C{theta} (with respect to the positive z-axis) and azimuthal angle C{phi} in
865 L{Degrees} I{or} L{Radians} representing a U{spherical, polar position
866 <https://WikiPedia.org/wiki/Spherical_coordinate_system>}.
867 '''
868 _Names_ = (_r_, _theta_, _phi_)
869 _Units_ = ( Meter, _Pass, _Pass)
871 def toCartesian(self, **name_Cartesian_and_kwds):
872 '''Convert this L{RadiusThetaPhi3Tuple} to a cartesian C{(x, y, z)} vector.
874 @kwarg name_Cartesian_and_kwds: Optional C{B{name}=NN}, overriding this
875 name and optional class C{B{Cartesian}=None} and additional
876 C{B{Cartesian}} keyword arguments.
878 @return: A C{B{Cartesian}(x, y, z)} instance or if no C{B{Cartesian}} keyword
879 argument is given, a L{Vector3Tuple}C{(x, y, z)} with C{x}, C{y}
880 and C{z} in the same units as radius C{r}, C{meter} conventionally.
882 @see: Function L{rtp2xyz_}.
883 '''
884 r, t, p = self
885 t, p, _ = _NamedTupleTo._Radians3(self, t, p)
886 return rtp2xyz_(r, t, p, **name_Cartesian_and_kwds)
888 def toDegrees(self, **name):
889 '''Convert this L{RadiusThetaPhi3Tuple}'s angles to L{Degrees}.
891 @kwarg name: Optional C{B{name}=NN} (C{str}), overriding this name.
893 @return: L{RadiusThetaPhi3Tuple}C{(r, theta, phi)} with C{theta}
894 and C{phi} both in L{Degrees}.
895 '''
896 return self._toX3U(_NamedTupleTo._Degrees3, Degrees, name)
898 def toRadians(self, **name):
899 '''Convert this L{RadiusThetaPhi3Tuple}'s angles to L{Radians}.
901 @kwarg name: Optional C{B{name}=NN} (C{str}), overriding this name.
903 @return: L{RadiusThetaPhi3Tuple}C{(r, theta, phi)} with C{theta}
904 and C{phi} both in L{Radians}.
905 '''
906 return self._toX3U(_NamedTupleTo._Radians3, Radians, name)
908 def _toU(self, U):
909 M = RadiusThetaPhi3Tuple._Units_[0] # Meter
910 return self.reUnit(M, U, U).toUnits()
912 def _toX3U(self, _X3, U, name):
913 r, t, p = self
914 t, p, s = _X3(self, t, p)
915 if s is None or name:
916 n = self._name__(name)
917 s = self.classof(r, t, p, name=n)._toU(U)
918 return s
921def rtp2xyz(r_rtp, theta=0, phi=0, **name_Cartesian_and_kwds):
922 '''Convert I{spherical, polar} C{(r, theta, phi)} to cartesian C{(x, y, z)} coordinates.
924 @arg theta: Inclination B{C{theta}} (C{degrees} with respect to the positive z-axis),
925 required if C{B{r_rtp}} is C{scalar}, ignored otherwise.
926 @arg phi: Azimuthal angle B{C{phi}} (C{degrees}), required if C{B{r_rtp}} is C{scalar},
927 ignored otherwise.
929 @see: Function L{rtp2xyz_} for further details.
930 '''
931 if isinstance(r_rtp, RadiusThetaPhi3Tuple):
932 c = r_rtp.toCartesian(**name_Cartesian_and_kwds)
933 else:
934 c = rtp2xyz_(r_rtp, radians(theta), radians(phi), **name_Cartesian_and_kwds)
935 return c
938def rtp2xyz_(r_rtp, theta=0, phi=0, **name_Cartesian_and_kwds):
939 '''Convert I{spherical, polar} C{(r, theta, phi)} to cartesian C{(x, y, z)} coordinates.
941 @arg r_rtp: Radial distance (C{scalar}, conventially C{meter}) or a previous
942 L{RadiusThetaPhi3Tuple} instance.
943 @arg theta: Inclination B{C{theta}} (C{radians} with respect to the positive z-axis),
944 required if C{B{r_rtp}} is C{scalar}, ignored otherwise.
945 @arg phi: Azimuthal angle B{C{phi}} (C{radians}), required if C{B{r_rtp}} is C{scalar},
946 ignored otherwise.
947 @kwarg name_Cartesian_and_kwds: Optional C{B{name}=NN} (C{str}), a C{B{Cartesian}=None}
948 class to return the coordinates and optional, additional C{B{Cartesian}}
949 keyword arguments.
951 @return: A C{B{Cartesian}(x, y, z)} instance or if no C{B{Cartesian}} keyword argument
952 is given a L{Vector3Tuple}C{(x, y, z)}, with C{x}, C{y} and C{z} in the same
953 units as radius C{r}, C{meter} conventionally.
955 @raise TypeError: Invalid B{C{r_rtp}}, B{C{theta}}, B{C{phi}} or
956 B{C{name_Cartesian_and_kwds}} item.
958 @see: U{Physics convention<https://WikiPedia.org/wiki/Spherical_coordinate_system>}
959 (ISO 80000-2:2019), class L{RadiusThetaPhi3Tuple} and functions L{rtp2xyz}
960 and L{xyz2rtp}.
961 '''
962 if isinstance(r_rtp, RadiusThetaPhi3Tuple):
963 c = r_rtp.toCartesian(**name_Cartesian_and_kwds)
964 elif _isMeter(r_rtp):
965 r = r_rtp
966 if r and _isfinite(r):
967 s, z, y, x = sincos2_(theta, phi)
968 s *= r
969 z *= r
970 y *= s
971 x *= s
972 else:
973 x = y = z = r
975 n, kwds = _name2__(**name_Cartesian_and_kwds)
976 C, kwds = _xkwds_pop2(kwds, Cartesian=None)
977 c = Vector3Tuple(x, y, z, name=n) if C is None else \
978 C(x, y, z, name=n, **kwds)
979 else:
980 raise _TypeError(r_rtp=r_rtp, theta=theta, phi=phi)
981 return c
984def _rtp3(where, U, *x_y_z, **name):
985 '''(INTERNAL) Helper for C{.toRtp}, C{xyz2rtp} and C{xyz2rtp_}.
986 '''
987 x, y, z = _MODS.vector3dBase._xyz3(where, *x_y_z)
988 r = hypot_(x, y, z)
989 if r > 0:
990 t = acos1(z / r)
991 p = atan2(y, x)
992 while p < 0:
993 p += PI2
994 if U is Degrees:
995 t = degrees(t)
996 p = degrees(p)
997 else:
998 t = p = _0_0
999 return RadiusThetaPhi3Tuple(r, t, p, **name)._toU(U)
1002def xyz2rtp(x_xyz, y=0, z=0, **name):
1003 '''Convert cartesian C{(x, y, z)} to I{spherical, polar} C{(r, theta, phi)} coordinates.
1005 @return: L{RadiusThetaPhi3Tuple}C{(r, theta, phi)} with C{theta} and C{phi}, both
1006 in L{Degrees}.
1008 @see: Function L{xyz2rtp_} for further details.
1009 '''
1010 return _rtp3(xyz2rtp, Degrees, x_xyz, y, z, **name)
1013def xyz2rtp_(x_xyz, y=0, z=0, **name):
1014 '''Convert cartesian C{(x, y, z)} to I{spherical, polar} C{(r, theta, phi)} coordinates.
1016 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian}, L{Ecef9Tuple},
1017 C{Nvector}, L{Vector3d}, L{Vector3Tuple}, L{Vector4Tuple} or a C{tuple} or
1018 C{list} of 3+ C{scalar} items) if no C{y_z} specified.
1019 @arg y: Y component (C{scalar}), required if C{B{x_xyz}} is C{scalar}, ignored otherwise.
1020 @arg z: Z component (C{scalar}), required if C{B{x_xyz}} is C{scalar}, ignored otherwise.
1021 @kwarg name: Optional C{B{name}=NN} (C{str}).
1023 @return: L{RadiusThetaPhi3Tuple}C{(r, theta, phi)} with radial distance C{r} (C{meter},
1024 same units as C{x}, C{y} and C{z}), inclination C{theta} (with respect to the
1025 positive z-axis) and azimuthal angle C{phi}, both in L{Radians}.
1027 @see: U{Physics convention<https://WikiPedia.org/wiki/Spherical_coordinate_system>}
1028 (ISO 80000-2:2019), class L{RadiusThetaPhi3Tuple} and function L{xyz2rtp}.
1029 '''
1030 return _rtp3(xyz2rtp_, Radians, x_xyz, y, z, **name)
1033__all__ += _ALL_DOCS(CartesianBase)
1035# **) MIT License
1036#
1037# Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved.
1038#
1039# Permission is hereby granted, free of charge, to any person obtaining a
1040# copy of this software and associated documentation files (the "Software"),
1041# to deal in the Software without restriction, including without limitation
1042# the rights to use, copy, modify, merge, publish, distribute, sublicense,
1043# and/or sell copies of the Software, and to permit persons to whom the
1044# Software is furnished to do so, subject to the following conditions:
1045#
1046# The above copyright notice and this permission notice shall be included
1047# in all copies or substantial portions of the Software.
1048#
1049# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1050# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1051# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1052# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
1053# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1054# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1055# OTHER DEALINGS IN THE SOFTWARE.