1

2# -*- coding: utf-8 -*-

3

4 u'''Triaxal ellipsoid classes I{ordered} L{Triaxial} and I{unordered} L{Triaxial_} and Jacobi

5 conformal projections L{JacobiConformal} and L{JacobiConformalSpherical}, transcoded from

6 I{Charles Karney}'s C++ class U{JacobiConformal<https://GeographicLib.SourceForge.io/C++/doc/

7 classGeographicLib_1_1JacobiConformal.html#details>} to pure Python and miscellaneous classes

8 L{BetaOmega2Tuple}, L{BetaOmega3Tuple}, L{Jacobi2Tuple} and L{TriaxialError}.

9

10 Copyright (C) U{Charles Karney<mailto:Karney@Alum.MIT.edu>} (2008-2023). For more information,

11 see the U{GeographicLib<https://GeographicLib.SourceForge.io>} documentation.

12

13@see: U{Geodesics on a triaxial ellipsoid<https://WikiPedia.org/wiki/Geodesics_on_an_ellipsoid#

14 Geodesics_on_a_triaxial_ellipsoid>} and U{Triaxial coordinate systems and their geometrical

15 interpretation<https://www.Topo.Auth.GR/wp-content/uploads/sites/111/2021/12/09_Panou.pdf>}.

16

17@var Triaxials.Amalthea: Triaxial(name='Amalthea', a=125000, b=73000, c=64000, e2ab=0.658944, e2bc=0.231375493, e2ac=0.737856, volume=2446253479595252, area=93239507787.490371704, area_p=93212299402.670425415)

18@var Triaxials.Ariel: Triaxial(name='Ariel', a=581100, b=577900, c=577700, e2ab=0.01098327, e2bc=0.000692042, e2ac=0.011667711, volume=812633172614203904, area=4211301462766.580078125, area_p=4211301574065.829589844)

19@var Triaxials.Earth: Triaxial(name='Earth', a=6378173.435, b=6378103.9, c=6356754.399999999, e2ab=0.000021804, e2bc=0.006683418, e2ac=0.006705077, volume=1083208241574987694080, area=510065911057441.0625, area_p=510065915922713.6875)

20@var Triaxials.Enceladus: Triaxial(name='Enceladus', a=256600, b=251400, c=248300, e2ab=0.040119337, e2bc=0.024509841, e2ac=0.06364586, volume=67094551514082248, area=798618496278.596679688, area_p=798619018175.109863281)

21@var Triaxials.Europa: Triaxial(name='Europa', a=1564130, b=1561230, c=1560930, e2ab=0.003704694, e2bc=0.000384275, e2ac=0.004087546, volume=15966575194402123776, area=30663773697323.51953125, area_p=30663773794562.45703125)

22@var Triaxials.Io: Triaxial(name='Io', a=1829400, b=1819300, c=1815700, e2ab=0.011011391, e2bc=0.003953651, e2ac=0.014921506, volume=25313121117889765376, area=41691875849096.7421875, area_p=41691877397441.2109375)

23@var Triaxials.Mars: Triaxial(name='Mars', a=3394600, b=3393300, c=3376300, e2ab=0.000765776, e2bc=0.009994646, e2ac=0.010752768, volume=162907283585817247744, area=144249140795107.4375, area_p=144249144150662.15625)

24@var Triaxials.Mimas: Triaxial(name='Mimas', a=207400, b=196800, c=190600, e2ab=0.09960581, e2bc=0.062015624, e2ac=0.155444317, volume=32587072869017956, area=493855762247.691894531, area_p=493857714107.9375)

25@var Triaxials.Miranda: Triaxial(name='Miranda', a=240400, b=234200, c=232900, e2ab=0.050915557, e2bc=0.011070811, e2ac=0.061422691, volume=54926187094835456, area=698880863325.756958008, area_p=698881306767.950317383)

26@var Triaxials.Moon: Triaxial(name='Moon', a=1735550, b=1735324, c=1734898, e2ab=0.000260419, e2bc=0.000490914, e2ac=0.000751206, volume=21886698675223740416, area=37838824729886.09375, area_p=37838824733332.2265625)

27@var Triaxials.Tethys: Triaxial(name='Tethys', a=535600, b=528200, c=525800, e2ab=0.027441672, e2bc=0.009066821, e2ac=0.036259685, volume=623086233855821440, area=3528073490771.394042969, area_p=3528074261832.738769531)

28@var Triaxials.WGS84_35: Triaxial(name='WGS84_35', a=6378172, b=6378102, c=6356752.314245179, e2ab=0.00002195, e2bc=0.006683478, e2ac=0.006705281, volume=1083207319768789942272, area=510065621722018.125, area_p=510065626587483.3125)

29'''

30# make sure int/int division yields float quotient, see .basics

31 from __future__ import division as _; del _ # PYCHOK semicolon

32

33 from pygeodesy.basics import isLatLon, isscalar, _zip, _ValueError

34 from pygeodesy.constants import EPS, EPS0, EPS02, EPS4, INT0, PI2, PI_3, PI4, \

35 _EPS2e4, float0_, isfinite, isnear1, _0_0, _0_5, \

36 _1_0, _N_1_0, _N_2_0, _4_0 # PYCHOK used!

37 from pygeodesy.datums import Datum, _spherical_datum, _WGS84, Ellipsoid, _EWGS84, Fmt

38# from pygeodesy.ellipsoids import Ellipsoid, _EWGS84 # from .datums

39# from pygeodesy.elliptic import Elliptic # _MODS

40# from pygeodesy.errors import _ValueError # from .basics

41 from pygeodesy.fmath import Fdot, fdot, fmean_, hypot, hypot_, norm2, sqrt0

42 from pygeodesy.fsums import _Fsumf_, fsumf_, fsum1f_

43 from pygeodesy.interns import NN, _a_, _b_, _beta_, _c_, _distant_, _finite_, \

44 _height_, _inside_, _near_, _negative_, _not_, \

45 _NOTEQUAL_, _null_, _opposite_, _outside_, _SPACE_, \

46 _spherical_, _too_, _x_, _y_

47# from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS # from .vector3d

48 from pygeodesy.named import _lazyNamedEnumItem as _lazy, _name__, _NamedEnum, \

49 _NamedEnumItem, _Pass

50 from pygeodesy.namedTuples import LatLon3Tuple, _NamedTupleTo, Vector3Tuple, \

51 Vector4Tuple

52 from pygeodesy.props import Property_RO, property_RO

53# from pygeodesy.streprs import Fmt # from .datums

54 from pygeodesy.units import Degrees, Float, Height_, Meter, Meter2, Meter3, \

55 Radians, Radius, Scalar_

56 from pygeodesy.utily import asin1, atan2d, km2m, m2km, SinCos2, sincos2d_

57 from pygeodesy.vector3d import _otherV3d, Vector3d, _ALL_LAZY, _MODS

58

59 from math import atan2, fabs, sqrt

60

61__all__ = _ALL_LAZY.triaxials

62__version__ = '24.06.24'

63

64_not_ordered_ = _not_('ordered')

65_omega_ = 'omega'

66_TRIPS = 269 # 48-55, Eberly 1074?

67

68

69 class _NamedTupleToX(_NamedTupleTo): # in .testNamedTuples

70 '''(INTERNAL) Base class for L{BetaOmega2Tuple},

71 L{BetaOmega3Tuple} and L{Jacobi2Tuple}.

72 '''

73 def _toDegrees(self, name, **toDMS_kwds):

74 '''(INTERNAL) Convert C{self[0:2]} to L{Degrees} or C{toDMS}.

75 '''

76 return self._toX3U(_NamedTupleTo._Degrees3, Degrees, name, *self, **toDMS_kwds)

77

78 def _toRadians(self, name):

79 '''(INTERNAL) Convert C{self[0:2]} to L{Radians}.

80 '''

81 return self._toX3U(_NamedTupleTo._Radians3, Radians, name, *self)

82

83 def _toX3U(self, _X3, U, name, a, b, *c, **kwds):

84 a, b, s = _X3(self, a, b, **kwds)

85 if s is None or name:

86 n = self._name__(name)

87 s = self.classof(a, b, *c, name=n).reUnit(U, U).toUnits()

88 return s

89

90

91 class BetaOmega2Tuple(_NamedTupleToX):

92 '''2-Tuple C{(beta, omega)} with I{ellipsoidal} lat- and

93 longitude C{beta} and C{omega} both in L{Radians} (or

94 L{Degrees}).

95 '''

96 _Names_ = (_beta_, _omega_)

97 _Units_ = (_Pass, _Pass)

98

99 def toDegrees(self, name=NN, **toDMS_kwds):

100 '''Convert this L{BetaOmega2Tuple} to L{Degrees} or C{toDMS}.

101

102 @kwarg name: Optional name (C{str}), overriding this name.

103

104 @return: L{BetaOmega2Tuple}C{(beta, omega)} with C{beta} and

105 C{omega} both in L{Degrees} or as L{toDMS} strings

106 provided some B{C{toDMS_kwds}} keyword arguments are

107 specified.

108 '''

109 return self._toDegrees(name, **toDMS_kwds)

110

111 def toRadians(self, **name):

112 '''Convert this L{BetaOmega2Tuple} to L{Radians}.

113

114 @kwarg name: Optional C{B{name}=NN} (C{str}), overriding this name.

115

116 @return: L{BetaOmega2Tuple}C{(beta, omega)} with C{beta} and C{omega}

117 both in L{Radians}.

118 '''

119 return self._toRadians(name)

120

121

122 class BetaOmega3Tuple(_NamedTupleToX):

123 '''3-Tuple C{(beta, omega, height)} with I{ellipsoidal} lat- and

124 longitude C{beta} and C{omega} both in L{Radians} (or L{Degrees})

125 and the C{height}, rather the (signed) I{distance} to the triaxial's

126 surface (measured along the radial line to the triaxial's center)

127 in C{meter}, conventionally.

128 '''

129 _Names_ = BetaOmega2Tuple._Names_ + (_height_,)

130 _Units_ = BetaOmega2Tuple._Units_ + ( Meter,)

131

132 def toDegrees(self, name=NN, **toDMS_kwds):

133 '''Convert this L{BetaOmega3Tuple} to L{Degrees} or C{toDMS}.

134

135 @kwarg name: Optional name (C{str}), overriding this name.

136

137 @return: L{BetaOmega3Tuple}C{(beta, omega, height)} with

138 C{beta} and C{omega} both in L{Degrees} or as

139 L{toDMS} strings provided some B{C{toDMS_kwds}}

140 keyword arguments are specified.

141 '''

142 return self._toDegrees(name, **toDMS_kwds)

143

144 def toRadians(self, **name):

145 '''Convert this L{BetaOmega3Tuple} to L{Radians}.

146

147 @kwarg name: Optional C{B{name}=NN} (C{str}), overriding this name.

148

149 @return: L{BetaOmega3Tuple}C{(beta, omega, height)} with C{beta}

150 and C{omega} both in L{Radians}.

151 '''

152 return self._toRadians(name)

153

154 def to2Tuple(self, **name):

155 '''Reduce this L{BetaOmega3Tuple} to a L{BetaOmega2Tuple}.

156

157 @kwarg name: Optional C{B{name}=NN} (C{str}), overriding this name.

158 '''

159 return BetaOmega2Tuple(*self[:2], name=self._name__(name))

160

161

162 class Jacobi2Tuple(_NamedTupleToX):

163 '''2-Tuple C{(x, y)} with a Jacobi Conformal C{x} and C{y}

164 projection, both in L{Radians} (or L{Degrees}).

165 '''

166 _Names_ = (_x_, _y_)

167 _Units_ = (_Pass, _Pass)

168

169 def toDegrees(self, name=NN, **toDMS_kwds):

170 '''Convert this L{Jacobi2Tuple} to L{Degrees} or C{toDMS}.

171

172 @kwarg name: Optional name (C{str}), overriding this name.

173

174 @return: L{Jacobi2Tuple}C{(x, y)} with C{x} and C{y} both

175 in L{Degrees} or as L{toDMS} strings provided some

176 B{C{toDMS_kwds}} keyword arguments are specified.

177 '''

178 return self._toDegrees(name, **toDMS_kwds)

179

180 def toRadians(self, **name):

181 '''Convert this L{Jacobi2Tuple} to L{Radians}.

182

183 @kwarg name: Optional C{B{name}=NN} (C{str}), overriding this name.

184

185 @return: L{Jacobi2Tuple}C{(x, y)} with C{x} and C{y} both in L{Radians}.

186 '''

187 return self._toRadians(name)

188

189

190 class Triaxial_(_NamedEnumItem):

191 '''I{Unordered} triaxial ellipsoid and base class.

192

193 Triaxial ellipsoids with right-handed semi-axes C{a}, C{b} and C{c}, oriented

194 such that the large principal ellipse C{ab} is the equator I{Z}=0, I{beta}=0,

195 while the small principal ellipse C{ac} is the prime meridian, plane I{Y}=0,

196 I{omega}=0.

197

198 The four umbilic points, C{abs}(I{omega}) = C{abs}(I{beta}) = C{PI/2}, lie on

199 the middle principal ellipse C{bc} in plane I{X}=0, I{omega}=C{PI/2}.

200

201 @note: I{Geodetic} C{lat}- and C{lon}gitudes are in C{degrees}, I{geodetic}

202 C{phi} and C{lam}bda are in C{radians}, but I{ellipsoidal} lat- and

203 longitude C{beta} and C{omega} are in L{Radians} by default (or in

204 L{Degrees} if converted).

205 '''

206 _ijk = _kji = None

207 _unordered = True

208

209 def __init__(self, a_triaxial, b=None, c=None, **name):

210 '''New I{unordered} L{Triaxial_}.

211

212 @arg a_triaxial: Large, C{X} semi-axis (C{scalar}, conventionally in

213 C{meter}) or an other L{Triaxial} or L{Triaxial_} instance.

214 @kwarg b: Middle, C{Y} semi-axis (C{meter}, same units as B{C{a}}), required

215 if C{B{a_triaxial} is scalar}, ignored otherwise.

216 @kwarg c: Small, C{Z} semi-axis (C{meter}, B{C{b}}).

217 @kwarg name: Optional C{B{name}=NN} (C{str}).

218

219 @raise TriaxialError: Invalid semi-axis or -axes.

220 '''

221 try:

222 try:

223 a = a_triaxial

224 t = a._abc3

225 except AttributeError:

226 t = Radius(a=a), Radius(b=b), Radius(c=c)

227 except (TypeError, ValueError) as x:

228 raise TriaxialError(a=a, b=b, c=c, cause=x)

229 if name:

230 self.name = name

231

232 a, b, c = self._abc3 = t

233 if self._unordered: # == not isinstance(self, Triaxial)

234 s, _, t = sorted(t)

235 if not (isfinite(t) and s > 0):

236 raise TriaxialError(a=a, b=b, c=c) # txt=_invalid_

237 elif not (isfinite(a) and a >= b >= c > 0):

238 raise TriaxialError(a=a, b=b, c=c, txt=_not_ordered_)

239 elif not (a > c and self._a2c2 > 0 and self.e2ac > 0):

240 raise TriaxialError(a=a, c=c, e2ac=self.e2ac, txt=_spherical_)

241

242 def __str__(self):

243 return self.toStr()

244

245 @Property_RO

246 def a(self):

247 '''Get the (largest) C{x} semi-axis (C{meter}, conventionally).

248 '''

249 a, _, _ = self._abc3

250 return a

251

252 @Property_RO

253 def _a2b2(self):

254 '''(INTERNAL) Get C{a**2 - b**2} == E_sub_e**2.

255 '''

256 a, b, _ = self._abc3

257 return ((a - b) * (a + b)) if a != b else _0_0

258

259 @Property_RO

260 def _a2_b2(self):

261 '''(INTERNAL) Get C{(a/b)**2}.

262 '''

263 a, b, _ = self._abc3

264 return (a / b)**2 if a != b else _1_0

265

266 @Property_RO

267 def _a2c2(self):

268 '''(INTERNAL) Get C{a**2 - c**2} == E_sub_x**2.

269 '''

270 a, _, c = self._abc3

271 return ((a - c) * (a + c)) if a != c else _0_0

272

273 @Property_RO

274 def area(self):

275 '''Get the surface area (C{meter} I{squared}).

276 '''

277 c, b, a = sorted(self._abc3)

278 if a > c:

279 a = Triaxial(a, b, c).area if a > b else \

280 Ellipsoid(a, b=c).areax # a == b

281 else: # a == c == b

282 a = Meter2(area=a**2 * PI4)

283 return a

284

285 def area_p(self, p=1.6075):

286 '''I{Approximate} the surface area (C{meter} I{squared}).

287

288 @kwarg p: Exponent (C{scalar} > 0), 1.6 for near-spherical or 1.5849625007

289 for "near-flat" triaxials.

290

291 @see: U{Surface area<https://WikiPedia.org/wiki/Ellipsoid#Approximate_formula>}.

292 '''

293 a, b, c = self._abc3

294 if a == b == c:

295 a *= a

296 else:

297 _p = pow

298 a = _p(fmean_(_p(a * b, p), _p(a * c, p), _p(b * c, p)), _1_0 / p)

299 return Meter2(area_p=a * PI4)

300

301 @Property_RO

302 def b(self):

303 '''Get the (middle) C{y} semi-axis (C{meter}, same units as B{C{a}}).

304 '''

305 _, b, _ = self._abc3

306 return b

307

308 @Property_RO

309 def _b2c2(self):

310 '''(INTERNAL) Get C{b**2 - c**2} == E_sub_y**2.

311 '''

312 _, b, c = self._abc3

313 return ((b - c) * (b + c)) if b != c else _0_0

314

315 @Property_RO

316 def c(self):

317 '''Get the (smallest) C{z} semi-axis (C{meter}, same units as B{C{a}}).

318 '''

319 _, _, c = self._abc3

320 return c

321

322 @Property_RO

323 def _c2_b2(self):

324 '''(INTERNAL) Get C{(c/b)**2}.

325 '''

326 _, b, c = self._abc3

327 return (c / b)**2 if b != c else _1_0

328

329 @Property_RO

330 def e2ab(self):

331 '''Get the C{ab} ellipse' I{(1st) eccentricity squared} (C{scalar}), M{1 - (b/a)**2}.

332 '''

333 return Float(e2ab=(_1_0 - self._1e2ab) or _0_0)

334

335 @Property_RO

336 def _1e2ab(self):

337 '''(INTERNAL) Get C{1 - e2ab} == C{(b/a)**2}.

338 '''

339 a, b, _ = self._abc3

340 return (b / a)**2 if a != b else _1_0

341

342 @Property_RO

343 def e2ac(self):

344 '''Get the C{ac} ellipse' I{(1st) eccentricity squared} (C{scalar}), M{1 - (c/a)**2}.

345 '''

346 return Float(e2ac=(_1_0 - self._1e2ac) or _0_0)

347

348 @Property_RO

349 def _1e2ac(self):

350 '''(INTERNAL) Get C{1 - e2ac} == C{(c/a)**2}.

351 '''

352 a, _, c = self._abc3

353 return (c / a)**2 if a != c else _1_0

354

355 @Property_RO

356 def e2bc(self):

357 '''Get the C{bc} ellipse' I{(1st) eccentricity squared} (C{scalar}), M{1 - (c/b)**2}.

358 '''

359 return Float(e2bc=(_1_0 - self._1e2bc) or _0_0)

360

361 _1e2bc = _c2_b2 # C{1 - e2bc} == C{(c/b)**2}

362

363 @property_RO

364 def _Elliptic(self):

365 '''(INTERNAL) Get class L{Elliptic}, I{once}.

366 '''

367 Triaxial_._Elliptic = E = _MODS.elliptic.Elliptic # overwrite property_RO

368 return E

369

370 def hartzell4(self, pov, los=False, **name):

371 '''Compute the intersection of this triaxial's surface with a Line-Of-Sight

372 from a Point-Of-View in space.

373

374 @see: Function L{hartzell4<triaxials.hartzell4>} for further details.

375 '''

376 return hartzell4(pov, los=los, tri_biax=self, **name)

377

378 def height4(self, x_xyz, y=None, z=None, normal=True, eps=EPS, **name):

379 '''Compute the projection on and the height above or below this triaxial's surface.

380

381 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian}, L{Ecef9Tuple},

382 L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

383 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar}, ignored

384 otherwise.

385 @kwarg z: Z component (C{scalar}), like B{C{y}}.

386 @kwarg normal: If C{True} the projection is the I{normal, plumb} to the surface of,

387 otherwise the C{radial} line to the center of this triaxial (C{bool}).

388 @kwarg eps: Tolerance for root finding and validation (C{scalar}), use a negative

389 value to skip validation.

390 @kwarg name: Optional C{B{name}="heigh4"} (C{str}).

391

392 @return: L{Vector4Tuple}C{(x, y, z, h)} with the cartesian coordinates C{x}, C{y}

393 and C{z} of the projection on or the intersection with and with the height

394 C{h} above or below the triaxial's surface in C{meter}, conventionally.

395

396 @raise TriaxialError: Non-cartesian B{C{xyz}}, invalid B{C{eps}}, no convergence in

397 root finding or validation failed.

398

399 @see: Method L{Ellipsoid.height4} and I{Eberly}'s U{Distance from a Point to ...

400 <https://www.GeometricTools.com/Documentation/DistancePointEllipseEllipsoid.pdf>}.

401 '''

402 v, r = _otherV3d_(x_xyz, y, z), self.isSpherical

403

404 i, h = None, v.length

405 if h < EPS0: # EPS

406 x = y = z = _0_0

407 h -= min(self._abc3) # nearest

408 elif r: # .isSpherical

409 x, y, z = v.times(r / h).xyz

410 h -= r

411 else:

412 x, y, z = v.xyz

413 try:

414 if normal: # plumb to surface

415 x, y, z, h, i = _plumbTo5(x, y, z, self, eps=eps)

416 else: # radial to center

417 x, y, z = self._radialTo3(z, hypot(x, y), y, x)

418 h = v.minus_(x, y, z).length

419 except Exception as e:

420 raise TriaxialError(x=x, y=y, z=z, cause=e)

421 if h > 0 and self.sideOf(v, eps=EPS0) < 0:

422 h = -h # below the surface

423 n = _name__(name, name__=self.height4)

424 return Vector4Tuple(x, y, z, h, iteration=i, name=n)

425

426 @Property_RO

427 def isOrdered(self):

428 '''Is this triaxial I{ordered} and I{not spherical} (C{bool})?

429 '''

430 a, b, c = self._abc3

431 return bool(a >= b > c) # b > c!

432

433 @Property_RO

434 def isSpherical(self):

435 '''Is this triaxial I{spherical} (C{Radius} or INT0)?

436 '''

437 a, b, c = self._abc3

438 return a if a == b == c else INT0

439

440 def _norm2(self, s, c, *a):

441 '''(INTERNAL) Normalize C{s} and C{c} iff not already.

442 '''

443 if fabs(_hypot21(s, c)) > EPS02:

444 s, c = norm2(s, c)

445 if a:

446 s, c = norm2(s * self.b, c * a[0])

447 return float0_(s, c)

448

449 def normal3d(self, x_xyz, y=None, z=None, length=_1_0):

450 '''Get a 3-D vector at a cartesian on and perpendicular to this triaxial's surface.

451

452 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian},

453 L{Ecef9Tuple}, L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

454 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar}, ignored

455 otherwise.

456 @kwarg z: Z component (C{scalar}), like B{C{y}}.

457 @kwarg length: Optional length and in-/outward direction (C{scalar}).

458

459 @return: A C{Vector3d(x_, y_, z_)} normalized to B{C{length}}, pointing

460 in- or outward for neg- respectively positive B{C{length}}.

461

462 @raise TriaxialError: Zero length cartesian or vector.

463

464 @note: Cartesian location C{(B{x}, B{y}, B{z})} must be on this triaxial's

465 surface, use method L{Triaxial.sideOf} to validate.

466 '''

467 # n = 2 * (x / a2, y / b2, z / c2)

468 # == 2 * (x, y * a2 / b2, z * a2 / c2) / a2 # iff ordered

469 # == 2 * (x, y / _1e2ab, z / _1e2ac) / a2

470 # == unit(x, y / _1e2ab, z / _1e2ac).times(length)

471 n = self._normal3d.times_(*_otherV3d_(x_xyz, y, z).xyz)

472 if n.length < EPS0:

473 raise TriaxialError(x=x_xyz, y=y, z=z, txt=_null_)

474 return n.times(length / n.length)

475

476 @Property_RO

477 def _normal3d(self):

478 '''(INTERNAL) Get M{Vector3d((d/a)**2, (d/b)**2, (d/c)**2)}, M{d = max(a, b, c)}.

479 '''

480 d = max(self._abc3)

481 t = tuple(((d / x)**2 if x != d else _1_0) for x in self._abc3)

482 return Vector3d(*t, name__=self.normal3d)

483

484 def _order3(self, *abc, **reverse): # reverse=False

485 '''(INTERNAL) Un-/Order C{a}, C{b} and C{c}.

486

487 @return: 3-Tuple C{(a, b, c)} ordered by or un-ordered

488 (reverse-ordered) C{ijk} if C{B{reverse}=True}.

489 '''

490 ijk = self._order_ijk(**reverse)

491 return _getitems(abc, *ijk) if ijk else abc

492

493 def _order3d(self, v, **reverse): # reverse=False

494 '''(INTERNAL) Un-/Order a C{Vector3d}.

495

496 @return: Vector3d(x, y, z) un-/ordered.

497 '''

498 ijk = self._order_ijk(**reverse)

499 return v.classof(*_getitems(v.xyz, *ijk)) if ijk else v

500

501 @Property_RO

502 def _ordered4(self):

503 '''(INTERNAL) Helper for C{_hartzell3} and C{_plumbTo5}.

504 '''

505 def _order2(reverse, a, b, c):

506 '''(INTERNAL) Un-Order C{a}, C{b} and C{c}.

507

508 @return: 2-Tuple C{((a, b, c), ijk)} with C{a} >= C{b} >= C{c}

509 and C{ijk} a 3-tuple with the initial indices.

510 '''

511 i, j, k = 0, 1, 2 # range(3)

512 if a < b:

513 a, b, i, j = b, a, j, i

514 if a < c:

515 a, c, i, k = c, a, k, i

516 if b < c:

517 b, c, j, k = c, b, k, j

518 # reverse (k, j, i) since (a, b, c) is reversed-sorted

519 ijk = (k, j, i) if reverse else (None if i < j < k else (i, j, k))

520 return (a, b, c), ijk

521

522 abc, T = self._abc3, self

523 if not self.isOrdered:

524 abc, ijk = _order2(False, *abc)

525 if ijk:

526 _, kji = _order2(True, *ijk)

527 T = Triaxial_(*abc)

528 T._ijk, T._kji = ijk, kji

529 return abc + (T,)

530

531 def _order_ijk(self, reverse=False):

532 '''(INTERNAL) Get the un-/order indices.

533 '''

534 return self._kji if reverse else self._ijk

535

536 def _radialTo3(self, sbeta, cbeta, somega, comega):

537 '''(INTERNAL) I{Unordered} helper for C{.height4}.

538 '''

539 def _rphi(a, b, sphi, cphi):

540 # <https://WikiPedia.org/wiki/Ellipse#Polar_form_relative_to_focus>

541 # polar form: radius(phi) = a * b / hypot(a * sphi, b * cphi)

542 return (b / hypot(sphi, b / a * cphi)) if a > b else (

543 (a / hypot(cphi, a / b * sphi)) if a < b else a)

544

545 sa, ca = self._norm2(sbeta, cbeta)

546 sb, cb = self._norm2(somega, comega)

547

548 a, b, c = self._abc3

549 if a != b:

550 a = _rphi(a, b, sb, cb)

551 if a != c:

552 c = _rphi(a, c, sa, ca)

553 z, r = c * sa, c * ca

554 x, y = r * cb, r * sb

555 return x, y, z

556

557 def sideOf(self, x_xyz, y=None, z=None, eps=EPS4):

558 '''Is a cartesian above, below or on the surface of this triaxial?

559

560 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian},

561 L{Ecef9Tuple}, L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

562 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar},

563 ignored otherwise.

564 @kwarg z: Z component (C{scalar}), like B{C{y}}.

565 @kwarg eps: Near-surface tolerance (C{scalar}, distance I{squared}).

566

567 @return: C{INT0} if C{(B{x}, B{y}, B{z})} is near this triaxial's surface

568 within tolerance B{C{eps}}, otherwise a signed, radial, normalized

569 distance I{squared} (C{float}), negative or positive for in-

570 respectively outside this triaxial.

571

572 @see: Methods L{Triaxial.height4} and L{Triaxial.normal3d}.

573 '''

574 return _sideOf(_otherV3d_(x_xyz, y, z).xyz, self._abc3, eps=eps)

575

576 def toEllipsoid(self, **name):

577 '''Convert this triaxial to an L{Ellipsoid}, provided 2 axes match.

578

579 @kwarg name: Optional, overriding C{B{name}=NN} (C{str})=.

580

581 @return: An L{Ellipsoid} with north along this C{Z} axis if C{a == b},

582 this C{Y} axis if C{a == c} or this C{X} axis if C{b == c}.

583

584 @raise TriaxialError: This C{a != b}, C{b != c} and C{c != a}.

585

586 @see: Method L{Ellipsoid.toTriaxial}.

587 '''

588 a, b, c = self._abc3

589 if a == b:

590 b = c # N = c-Z

591 elif b == c: # N = a-X

592 a, b = b, a

593 elif a != c: # N = b-Y

594 t = _SPACE_(_a_, _NOTEQUAL_, _b_, _NOTEQUAL_, _c_)

595 raise TriaxialError(a=a, b=b, c=c, txt=t)

596 return Ellipsoid(a, b=b, name=self._name__(name))

597

598 def toStr(self, prec=9, **name): # PYCHOK signature

599 '''Return this C{Triaxial} as a string.

600

601 @kwarg prec: Precision, number of decimal digits (0..9).

602 @kwarg name: Optional, overriding C{B{name}=NN} (C{str})

603 or C{None} to exclude this triaxial's name.

604

605 @return: This C{Triaxial}'s attributes (C{str}).

606 '''

607 T = Triaxial_

608 t = T.a,

609 J = JacobiConformalSpherical

610 t += (J.ab, J.bc) if isinstance(self, J) else (T.b, T.c)

611 t += T.e2ab, T.e2bc, T.e2ac

612 J = JacobiConformal

613 if isinstance(self, J):

614 t += J.xyQ2,

615 t += T.volume, T.area

616 return self._instr(area_p=self.area_p(), prec=prec, props=t, **name)

617

618 @Property_RO

619 def volume(self):

620 '''Get the volume (C{meter**3}), M{4 / 3 * PI * a * b * c}.

621 '''

622 a, b, c = self._abc3

623 return Meter3(volume=a * b * c * PI_3 * _4_0)

624

625

626 class Triaxial(Triaxial_):

627 '''I{Ordered} triaxial ellipsoid.

628

629 @see: L{Triaxial_} for more information.

630 '''

631 _unordered = False

632

633 def __init__(self, a_triaxial, b=None, c=None, **name):

634 '''New I{ordered} L{Triaxial}.

635

636 @arg a_triaxial: Largest semi-axis (C{scalar}, conventionally in C{meter})

637 or an other L{Triaxial} or L{Triaxial_} instance.

638 @kwarg b: Middle semi-axis (C{meter}, same units as B{C{a}}), required

639 if C{B{a_triaxial} is scalar}, ignored otherwise.

640 @kwarg c: Smallest semi-axis (C{meter}, like B{C{b}}).

641 @kwarg name: Optional C{B{name}=NN} (C{str}).

642

643 @note: The semi-axes must be ordered as C{B{a} >= B{b} >= B{c} > 0} and

644 must be ellipsoidal, C{B{a} > B{c}}.

645

646 @raise TriaxialError: Semi-axes unordered, spherical or invalid.

647 '''

648 Triaxial_.__init__(self, a_triaxial, b=b, c=c, **name)

649

650 @Property_RO

651 def _a2b2_a2c2(self):

652 '''@see: Methods C{.forwardBetaOmega} and C{._k2_kp2}.

653 '''

654 return self._a2b2 / self._a2c2

655

656 @Property_RO

657 def area(self):

658 '''Get the surface area (C{meter} I{squared}).

659

660 @see: U{Surface area<https://WikiPedia.org/wiki/Ellipsoid#Surface_area>}.

661 '''

662 a, b, c = self._abc3

663 if a != b:

664 kp2, k2 = self._k2_kp2 # swapped!

665 aE = self._Elliptic(k2, _0_0, kp2, _1_0)

666 c2 = self._1e2ac # cos(phi)**2 = (c/a)**2

667 s = sqrt(self.e2ac) # sin(phi)**2 = 1 - c2

668 r = asin1(s) # phi = atan2(sqrt(c2), s)

669 b *= fsum1f_(aE.fE(r) * s, c / a * c / b,

670 aE.fF(r) * c2 / s)

671 a = Meter2(area=a * b * PI2)

672 else: # a == b > c

673 a = Ellipsoid(a, b=c).areax

674 return a

675

676 def _exyz3(self, u):

677 '''(INTERNAL) Helper for C{.forwardBetOmg}.

678 '''

679 if u > 0:

680 u2 = u**2

681 x = u * sqrt0(_1_0 + self._a2c2 / u2, Error=TriaxialError)

682 y = u * sqrt0(_1_0 + self._b2c2 / u2, Error=TriaxialError)

683 else:

684 x = y = u = _0_0

685 return x, y, u

686

687 def forwardBetaOmega(self, beta, omega, height=0, **name):

688 '''Convert I{ellipsoidal} lat- and longitude C{beta}, C{omega}

689 and height to cartesian.

690

691 @arg beta: Ellipsoidal latitude (C{radians} or L{Degrees}).

692 @arg omega: Ellipsoidal longitude (C{radians} or L{Degrees}).

693 @arg height: Height above or below the ellipsoid's surface (C{meter}, same

694 units as this triaxial's C{a}, C{b} and C{c} semi-axes).

695 @kwarg name: Optional C{B{name}=NN} (C{str}).

696

697 @return: A L{Vector3Tuple}C{(x, y, z)}.

698

699 @see: Method L{Triaxial.reverseBetaOmega} and U{Expressions (23-25)<https://

700 www.Topo.Auth.GR/wp-content/uploads/sites/111/2021/12/09_Panou.pdf>}.

701 '''

702 if height:

703 h = self._Height(height)

704 x, y, z = self._exyz3(h + self.c)

705 else:

706 x, y, z = self._abc3 # == self._exyz3(self.c)

707 if z: # and x and y:

708 sa, ca = SinCos2(beta)

709 sb, cb = SinCos2(omega)

710

711 r = self._a2b2_a2c2

712 x *= cb * sqrt0(ca**2 + r * sa**2, Error=TriaxialError)

713 y *= ca * sb

714 z *= sa * sqrt0(_1_0 - r * cb**2, Error=TriaxialError)

715 return Vector3Tuple(x, y, z, **name)

716

717 def forwardBetaOmega_(self, sbeta, cbeta, somega, comega, **name):

718 '''Convert I{ellipsoidal} lat- and longitude C{beta} and C{omega}

719 to cartesian coordinates I{on the triaxial's surface}.

720

721 @arg sbeta: Ellipsoidal latitude C{sin(beta)} (C{scalar}).

722 @arg cbeta: Ellipsoidal latitude C{cos(beta)} (C{scalar}).

723 @arg somega: Ellipsoidal longitude C{sin(omega)} (C{scalar}).

724 @arg comega: Ellipsoidal longitude C{cos(omega)} (C{scalar}).

725 @kwarg name: Optional C{B{name}=NN} (C{str}).

726

727 @return: A L{Vector3Tuple}C{(x, y, z)} on the surface.

728

729 @raise TriaxialError: This triaxial is near-spherical.

730

731 @see: Method L{Triaxial.reverseBetaOmega}, U{Triaxial ellipsoid coordinate

732 system<https://WikiPedia.org/wiki/Geodesics_on_an_ellipsoid#

733 Triaxial_ellipsoid_coordinate_system>} and U{expressions (23-25)<https://

734 www.Topo.Auth.GR/wp-content/uploads/sites/111/2021/12/09_Panou.pdf>}.

735 '''

736 t = self._radialTo3(sbeta, cbeta, somega, comega)

737 return Vector3Tuple(*t, **name)

738

739 def forwardCartesian(self, x_xyz, y=None, z=None, **normal_eps_name):

740 '''Project a cartesian on this triaxial.

741

742 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian},

743 L{Ecef9Tuple}, L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

744 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar},

745 ignored otherwise.

746 @kwarg z: Z component (C{scalar}), like B{C{y}}.

747 @kwarg normal_eps_name: Optional keyword arguments C{B{normal}=True},

748 C{B{eps}=EPS} and overriding C{B{name}="height4"} (C{str}),

749 see method L{Triaxial.height4}.

750

751 @see: Method L{Triaxial.height4} for further information and method

752 L{Triaxial.reverseCartesian} to reverse the projection.

753 '''

754 return self.height4(x_xyz, y, z, **normal_eps_name)

755

756 def forwardLatLon(self, lat, lon, height=0, **name):

757 '''Convert I{geodetic} lat-, longitude and heigth to cartesian.

758

759 @arg lat: Geodetic latitude (C{degrees}).

760 @arg lon: Geodetic longitude (C{degrees}).

761 @arg height: Height above the ellipsoid (C{meter}, same units

762 as this triaxial's C{a}, C{b} and C{c} axes).

763 @kwarg name: Optional C{B{name}=NN} (C{str}).

764

765 @return: A L{Vector3Tuple}C{(x, y, z)}.

766

767 @see: Method L{Triaxial.reverseLatLon} and U{Expressions (9-11)<https://

768 www.Topo.Auth.GR/wp-content/uploads/sites/111/2021/12/09_Panou.pdf>}.

769 '''

770 return self._forwardLatLon3(height, name, *sincos2d_(lat, lon))

771

772 def forwardLatLon_(self, slat, clat, slon, clon, height=0, **name):

773 '''Convert I{geodetic} lat-, longitude and heigth to cartesian.

774

775 @arg slat: Geodetic latitude C{sin(lat)} (C{scalar}).

776 @arg clat: Geodetic latitude C{cos(lat)} (C{scalar}).

777 @arg slon: Geodetic longitude C{sin(lon)} (C{scalar}).

778 @arg clon: Geodetic longitude C{cos(lon)} (C{scalar}).

779 @arg height: Height above the ellipsoid (C{meter}, same units

780 as this triaxial's axes C{a}, C{b} and C{c}).

781 @kwarg name: Optional C{B{name}=NN} (C{str}).

782

783 @return: A L{Vector3Tuple}C{(x, y, z)}.

784

785 @see: Method L{Triaxial.reverseLatLon} and U{Expressions (9-11)<https://

786 www.Topo.Auth.GR/wp-content/uploads/sites/111/2021/12/09_Panou.pdf>}.

787 '''

788 sa, ca = self._norm2(slat, clat)

789 sb, cb = self._norm2(slon, clon)

790 return self._forwardLatLon3(height, name, sa, ca, sb, cb)

791

792 def _forwardLatLon3(self, height, name, sa, ca, sb, cb): # name always **name

793 '''(INTERNAL) Helper for C{.forwardLatLon} and C{.forwardLatLon_}.

794 '''

795 ca_x_sb = ca * sb

796 h = self._Height(height)

797 # 1 - (1 - (c/a)**2) * sa**2 - (1 - (b/a)**2) * ca**2 * sb**2

798 t = fsumf_(_1_0, -self.e2ac * sa**2, -self.e2ab * ca_x_sb**2)

799 n = self.a / sqrt0(t, Error=TriaxialError) # prime vertical

800 x = (h + n) * ca * cb

801 y = (h + n * self._1e2ab) * ca_x_sb

802 z = (h + n * self._1e2ac) * sa

803 return Vector3Tuple(x, y, z, **name)

804

805 def _Height(self, height):

806 '''(INTERNAL) Validate a C{height}.

807 '''

808 return Height_(height=height, low=-self.c, Error=TriaxialError)

809

810 @Property_RO

811 def _k2_kp2(self):

812 '''(INTERNAL) Get C{k2} and C{kp2} for C{._xE}, C{._yE} and C{.area}.

813 '''

814 # k2 = a2b2 / a2c2 * c2_b2

815 # kp2 = b2c2 / a2c2 * a2_b2

816 # b2 = b**2

817 # xE = Elliptic(k2, -a2b2 / b2, kp2, a2_b2)

818 # yE = Elliptic(kp2, +b2c2 / b2, k2, c2_b2)

819 # aE = Elliptic(kp2, 0, k2, 1)

820 return (self._a2b2_a2c2 * self._c2_b2,

821 self._b2c2 / self._a2c2 * self._a2_b2)

822

823 def _radialTo3(self, sbeta, cbeta, somega, comega):

824 '''(INTERNAL) Convert I{ellipsoidal} lat- and longitude C{beta} and

825 C{omega} to cartesian coordinates I{on the triaxial's surface},

826 also I{ordered} helper for C{.height4}.

827 '''

828 sa, ca = self._norm2(sbeta, cbeta)

829 sb, cb = self._norm2(somega, comega)

830

831 b2_a2 = self._1e2ab # == (b/a)**2

832 c2_a2 = -self._1e2ac # == -(c/a)**2

833 a2c2_a2 = self. e2ac # (a**2 - c**2) / a**2 == 1 - (c/a)**2

834

835 x2 = _Fsumf_(_1_0, -b2_a2 * sa**2, c2_a2 * ca**2).fover(a2c2_a2)

836 z2 = _Fsumf_(c2_a2, sb**2, b2_a2 * cb**2).fover(a2c2_a2)

837

838 x, y, z = self._abc3

839 x *= cb * sqrt0(x2, Error=TriaxialError)

840 y *= ca * sb

841 z *= sa * sqrt0(z2, Error=TriaxialError)

842 return x, y, z

843

844 def reverseBetaOmega(self, x_xyz, y=None, z=None, **name):

845 '''Convert cartesian to I{ellipsoidal} lat- and longitude, C{beta}, C{omega}

846 and height.

847

848 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian},

849 L{Ecef9Tuple}, L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

850 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar},

851 ignored otherwise.

852 @kwarg z: Z component (C{scalar}), like B{C{y}}.

853 @kwarg name: Optional C{B{name}=NN} (C{str}).

854

855 @return: A L{BetaOmega3Tuple}C{(beta, omega, height)} with C{beta} and

856 C{omega} in L{Radians} and (radial) C{height} in C{meter}, same

857 units as this triaxial's axes.

858

859 @see: Methods L{Triaxial.forwardBetaOmega} and L{Triaxial.forwardBetaOmega_}

860 and U{Expressions (21-22)<https://www.Topo.Auth.GR/wp-content/uploads/

861 sites/111/2021/12/09_Panou.pdf>}.

862 '''

863 v = _otherV3d_(x_xyz, y, z)

864 a, b, h = self._reverseLatLon3(v, atan2, v, self.forwardBetaOmega_)

865 return BetaOmega3Tuple(Radians(beta=a), Radians(omega=b), h, **name)

866

867 def reverseCartesian(self, x_xyz, y=None, z=None, h=0, normal=True, eps=_EPS2e4, **name):

868 '''"Unproject" a cartesian on to a cartesion I{off} this triaxial's surface.

869

870 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian},

871 L{Ecef9Tuple}, L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

872 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar},

873 ignored otherwise.

874 @kwarg z: Z component (C{scalar}), like B{C{y}}.

875 @arg h: Height above or below this triaxial's surface (C{meter}, same units

876 as the axes).

877 @kwarg normal: If C{True} the height is C{normal} to the surface, otherwise

878 C{radially} to the center of this triaxial (C{bool}).

879 @kwarg eps: Tolerance for surface test (C{scalar}).

880 @kwarg name: Optional C{B{name}=NN} (C{str}).

881

882 @return: A L{Vector3Tuple}C{(x, y, z)}.

883

884 @raise TrialError: Cartesian C{(x, y, z)} not on this triaxial's surface.

885

886 @see: Methods L{Triaxial.forwardCartesian} and L{Triaxial.height4}.

887 '''

888 v = _otherV3d_(x_xyz, y, z, **name)

889 s = _sideOf(v.xyz, self._abc3, eps=eps)

890 if s: # PYCHOK no cover

891 t = _SPACE_((_inside_ if s < 0 else _outside_), self.toRepr())

892 raise TriaxialError(eps=eps, sideOf=s, x=v.x, y=v.y, z=v.z, txt=t)

893

894 if h:

895 if normal:

896 v = v.plus(self.normal3d(*v.xyz, length=h))

897 elif v.length > EPS0:

898 v = v.times(_1_0 + (h / v.length))

899 return v.xyz # Vector3Tuple

900

901 def reverseLatLon(self, x_xyz, y=None, z=None, **name):

902 '''Convert cartesian to I{geodetic} lat-, longitude and height.

903

904 @arg x_xyz: X component (C{scalar}) or a cartesian (C{Cartesian},

905 L{Ecef9Tuple}, L{Vector3d}, L{Vector3Tuple} or L{Vector4Tuple}).

906 @kwarg y: Y component (C{scalar}), required if B{C{x_xyz}} if C{scalar},

907 ignored otherwise.

908 @kwarg z: Z component (C{scalar}), like B{C{y}}.

909 @kwarg name: Optional C{B{name}=NN} (C{str}).

910

911 @return: A L{LatLon3Tuple}C{(lat, lon, height)} with C{lat} and C{lon}

912 in C{degrees} and (radial) C{height} in C{meter}, same units

913 as this triaxial's axes.

914

915 @see: Methods L{Triaxial.forwardLatLon} and L{Triaxial.forwardLatLon_}

916 and U{Expressions (4-5)<https://www.Topo.Auth.GR/wp-content/uploads/

917 sites/111/2021/12/09_Panou.pdf>}.

918 '''

919 v = _otherV3d_(x_xyz, y, z)

920 s = v.times_(self._1e2ac, # == 1 - e_sub_x**2

921 self._1e2bc, # == 1 - e_sub_y**2

922 _1_0)

923 a, b, h = self._reverseLatLon3(s, atan2d, v, self.forwardLatLon_)

924 return LatLon3Tuple(Degrees(lat=a), Degrees(lon=b), h, **name)

925

926 def _reverseLatLon3(self, s, atan2_, v, forward_):

927 '''(INTERNAL) Helper for C{.reverseBetOmg} and C{.reverseLatLon}.

928 '''

929 x, y, z = s.xyz

930 d = hypot( x, y)

931 a = atan2_(z, d)

932 b = atan2_(y, x)

933 h = v.minus_(*forward_(z, d, y, x)).length

934 return a, b, h

935

936

937 class JacobiConformal(Triaxial):

938 '''This is a conformal projection of a triaxial ellipsoid to a plane in which the

939 C{X} and C{Y} grid lines are straight.

940

941 Ellipsoidal coordinates I{beta} and I{omega} are converted to Jacobi Conformal

942 I{y} respectively I{x} separately. Jacobi's coordinates have been multiplied

943 by C{sqrt(B{a}**2 - B{c}**2) / (2 * B{b})} so that the customary results are

944 returned in the case of an ellipsoid of revolution.

945

946 Copyright (C) U{Charles Karney<mailto:Karney@Alum.MIT.edu>} (2014-2023) and

947 licensed under the MIT/X11 License.

948

949 @note: This constructor can I{not be used to specify a sphere}, see alternate

950 L{JacobiConformalSpherical}.

951

952 @see: L{Triaxial}, C++ class U{JacobiConformal<https://GeographicLib.SourceForge.io/

953 C++/doc/classGeographicLib_1_1JacobiConformal.html#details>}, U{Jacobi's conformal

954 projection<https://GeographicLib.SourceForge.io/C++/doc/jacobi.html>} and Jacobi,

955 C. G. J. I{U{Vorlesungen über Dynamik<https://Books.Google.com/books?

956 id=ryEOAAAAQAAJ&pg=PA212>}}, page 212ff.

957 '''

958

959 @Property_RO

960 def _xE(self):

961 '''(INTERNAL) Get the x-elliptic function.

962 '''

963 k2, kp2 = self._k2_kp2

964 # -a2b2 / b2 == (b2 - a2) / b2 == 1 - a2 / b2 == 1 - a2_b2

965 return self._Elliptic(k2, _1_0 - self._a2_b2, kp2, self._a2_b2)

966

967 def xR(self, omega):

968 '''Compute a Jacobi Conformal C{x} projection.

969

970 @arg omega: Ellipsoidal longitude (C{radians} or L{Degrees}).

971

972 @return: The C{x} projection (L{Radians}).

973 '''

974 return self.xR_(*SinCos2(omega))

975

976 def xR_(self, somega, comega):

977 '''Compute a Jacobi Conformal C{x} projection.

978

979 @arg somega: Ellipsoidal longitude C{sin(omega)} (C{scalar}).

980 @arg comega: Ellipsoidal longitude C{cos(omega)} (C{scalar}).

981

982 @return: The C{x} projection (L{Radians}).

983 '''

984 s, c = self._norm2(somega, comega, self.a)

985 return Radians(x=self._xE.fPi(s, c) * self._a2_b2)

986

987 @Property_RO

988 def xyQ2(self):

989 '''Get the Jacobi Conformal quadrant size (L{Jacobi2Tuple}C{(x, y)}).

990 '''

991 return Jacobi2Tuple(Radians(x=self._a2_b2 * self._xE.cPi),

992 Radians(y=self._c2_b2 * self._yE.cPi),

993 name=JacobiConformal.xyQ2.name)

994

995 def xyR2(self, beta, omega, **name):

996 '''Compute a Jacobi Conformal C{x} and C{y} projection.

997

998 @arg beta: Ellipsoidal latitude (C{radians} or L{Degrees}).

999 @arg omega: Ellipsoidal longitude (C{radians} or L{Degrees}).

1000 @kwarg name: Optional, overriding C{B{name}="xyR2"} (C{str}).

1001

1002 @return: A L{Jacobi2Tuple}C{(x, y)}.

1003 '''

1004 return self.xyR2_(*(SinCos2(beta) + SinCos2(omega)),

1005 name=_name__(name, name__=self.xyR2))

1006

1007 def xyR2_(self, sbeta, cbeta, somega, comega, **name):

1008 '''Compute a Jacobi Conformal C{x} and C{y} projection.

1009

1010 @arg sbeta: Ellipsoidal latitude C{sin(beta)} (C{scalar}).

1011 @arg cbeta: Ellipsoidal latitude C{cos(beta)} (C{scalar}).

1012 @arg somega: Ellipsoidal longitude C{sin(omega)} (C{scalar}).

1013 @arg comega: Ellipsoidal longitude C{cos(omega)} (C{scalar}).

1014 @kwarg name: Optional, overriding C{B{name}="xyR2_"} (C{str}).

1015

1016 @return: A L{Jacobi2Tuple}C{(x, y)}.

1017 '''

1018 return Jacobi2Tuple(self.xR_(somega, comega),

1019 self.yR_(sbeta, cbeta),

1020 name=_name__(name, name__=self.xyR2_))

1021

1022 @Property_RO

1023 def _yE(self):

1024 '''(INTERNAL) Get the x-elliptic function.

1025 '''

1026 kp2, k2 = self._k2_kp2 # swapped!

1027 # b2c2 / b2 == (b2 - c2) / b2 == 1 - c2 / b2 == e2bc

1028 return self._Elliptic(k2, self.e2bc, kp2, self._c2_b2)

1029

1030 def yR(self, beta):

1031 '''Compute a Jacobi Conformal C{y} projection.

1032

1033 @arg beta: Ellipsoidal latitude (C{radians} or L{Degrees}).

1034

1035 @return: The C{y} projection (L{Radians}).

1036 '''

1037 return self.yR_(*SinCos2(beta))

1038

1039 def yR_(self, sbeta, cbeta):

1040 '''Compute a Jacobi Conformal C{y} projection.

1041

1042 @arg sbeta: Ellipsoidal latitude C{sin(beta)} (C{scalar}).

1043 @arg cbeta: Ellipsoidal latitude C{cos(beta)} (C{scalar}).

1044

1045 @return: The C{y} projection (L{Radians}).

1046 '''

1047 s, c = self._norm2(sbeta, cbeta, self.c)

1048 return Radians(y=self._yE.fPi(s, c) * self._c2_b2)

1049

1050

1051 class JacobiConformalSpherical(JacobiConformal):

1052 '''An alternate, I{spherical} L{JacobiConformal} projection.

1053

1054 @see: L{JacobiConformal} for other and more details.

1055 '''

1056 _ab = _bc = 0

1057

1058 def __init__(self, radius_triaxial, ab=0, bc=0, **name):

1059 '''New L{JacobiConformalSpherical}.

1060

1061 @arg radius_triaxial: Radius (C{scalar}, conventionally in

1062 C{meter}) or an other L{JacobiConformalSpherical},

1063 L{JacobiConformal} or ordered L{Triaxial}.

1064 @kwarg ab: Relative magnitude of C{B{a} - B{b}} (C{meter},

1065 same units as C{scalar B{radius}}.

1066 @kwarg bc: Relative magnitude of C{B{b} - B{c}} (C{meter},

1067 same units as C{scalar B{radius}}.

1068 @kwarg name: Optional C{B{name}=NN} (C{str}).

1069

1070 @raise TriaxialError: Invalid B{C{radius_triaxial}}, negative

1071 B{C{ab}}, negative B{C{bc}} or C{(B{ab}

1072 + B{bc})} not positive.

1073

1074 @note: If B{C{radius_triaxial}} is a L{JacobiConformalSpherical}

1075 and if B{C{ab}} and B{C{bc}} are both zero or C{None},

1076 the B{C{radius_triaxial}}'s C{ab}, C{bc}, C{a}, C{b}

1077 and C{c} are copied.

1078 '''

1079 try:

1080 r = radius_triaxial

1081 if isinstance(r, Triaxial): # ordered only

1082 t = r._abc3

1083 j = isinstance(r, JacobiConformalSpherical) and not bool(ab or bc)

1084 else:

1085 t = (Radius(radius=r),) * 3

1086 j = False

1087 self._ab = r.ab if j else Scalar_(ab=ab) # low=0

1088 self._bc = r.bc if j else Scalar_(bc=bc) # low=0

1089 if (self.ab + self.bc) <= 0:

1090 raise ValueError(_negative_)

1091 a, _, c = self._abc3 = t

1092 if not (a >= c and isfinite(self._a2b2)

1093 and isfinite(self._a2c2)):

1094 raise ValueError(_not_(_finite_))

1095 except (TypeError, ValueError) as x:

1096 raise TriaxialError(radius_triaxial=r, ab=ab, bc=bc, cause=x)

1097 if name:

1098 self.name = name

1099

1100 @Property_RO

1101 def ab(self):

1102 '''Get relative magnitude C{ab} (C{meter}, same units as B{C{a}}).

1103 '''

1104 return self._ab

1105

1106 @Property_RO

1107 def _a2b2(self):

1108 '''(INTERNAL) Get C{a**2 - b**2} == ab * (a + b).

1109 '''

1110 a, b, _ = self._abc3

1111 return self.ab * (a + b)

1112

1113 @Property_RO

1114 def _a2c2(self):

1115 '''(INTERNAL) Get C{a**2 - c**2} == a2b2 + b2c2.

1116 '''

1117 return self._a2b2 + self._b2c2

1118

1119 @Property_RO

1120 def bc(self):

1121 '''Get relative magnitude C{bc} (C{meter}, same units as B{C{a}}).

1122 '''

1123 return self._bc

1124

1125 @Property_RO

1126 def _b2c2(self):

1127 '''(INTERNAL) Get C{b**2 - c**2} == bc * (b + c).

1128 '''

1129 _, b, c = self._abc3

1130 return self.bc * (b + c)

1131

1132 @Property_RO

1133 def radius(self):

1134 '''Get radius (C{meter}, conventionally).

1135 '''

1136 return self.a

1137

1138

1139 class TriaxialError(_ValueError):

1140 '''Raised for L{Triaxial} issues.

1141 '''

1142 pass # ...

1143

1144

1145 class Triaxials(_NamedEnum):

1146 '''(INTERNAL) L{Triaxial} registry, I{must} be a sub-class

1147 to accommodate the L{_LazyNamedEnumItem} properties.

1148 '''

1149 def _Lazy(self, *abc, **name):

1150 '''(INTERNAL) Instantiate the C{Triaxial}.

1151 '''

1152 a, b, c = map(km2m, abc)

1153 return Triaxial(a, b, c, **name)

1154

1155 Triaxials = Triaxials(Triaxial, Triaxial_) # PYCHOK singleton

1156'''Some pre-defined L{Triaxial}s, all I{lazily} instantiated.'''

1157# <https://ArxIV.org/pdf/1909.06452.pdf> Table 1 Semi-axes in Km

1158# <https://www.JPS.NASA.gov/education/images/pdf/ss-moons.pdf>

1159# <https://link.Springer.com/article/10.1007/s00190-022-01650-9>

1160_abc84_35 = (_EWGS84.a + 35), (_EWGS84.a - 35), _EWGS84.b

1161 Triaxials._assert( # a (Km) b (Km) c (Km) planet

1162 Amalthea = _lazy('Amalthea', 125.0, 73.0, 64), # Jupiter

1163 Ariel = _lazy('Ariel', 581.1, 577.9, 577.7), # Uranus

1164 Earth = _lazy('Earth', 6378.173435, 6378.1039, 6356.7544),

1165 Enceladus = _lazy('Enceladus', 256.6, 251.4, 248.3), # Saturn

1166 Europa = _lazy('Europa', 1564.13, 1561.23, 1560.93), # Jupiter

1167 Io = _lazy('Io', 1829.4, 1819.3, 1815.7), # Jupiter

1168 Mars = _lazy('Mars', 3394.6, 3393.3, 3376.3),

1169 Mimas = _lazy('Mimas', 207.4, 196.8, 190.6), # Saturn

1170 Miranda = _lazy('Miranda', 240.4, 234.2, 232.9), # Uranus

1171 Moon = _lazy('Moon', 1735.55, 1735.324, 1734.898), # Earth

1172 Tethys = _lazy('Tethys', 535.6, 528.2, 525.8), # Saturn

1173 WGS84_35 = _lazy('WGS84_35', *map(m2km, _abc84_35)))

1174 del _abc84_35, _EWGS84

1175

1176

1177 def _getitems(items, *indices):

1178 '''(INTERNAL) Get the C{items} at the given I{indices}.

1179

1180 @return: C{Type(items[i] for i in indices)} with

1181 C{Type = type(items)}, any C{type} having

1182 the special method C{__getitem__}.

1183 '''

1184 return type(items)(map(items.__getitem__, indices))

1185

1186

1187 def _hartzell3(pov, los, Tun): # in .Ellipsoid.hartzell4, .formy.hartzell

1188 '''(INTERNAL) Hartzell's "Satellite Line-of-Sight Intersection ...",

1189 formula from a Point-Of-View to an I{un-/ordered} Triaxial.

1190 '''

1191 def _toUvwV3d(los, pov):

1192 try: # pov must be LatLon or Cartesian if los is a Los

1193 v = los.toUvw(pov)

1194 except (AttributeError, TypeError):

1195 v = _otherV3d(los=los)

1196 return v

1197

1198 p3 = _otherV3d(pov=pov.toCartesian() if isLatLon(pov) else pov)

1199 if los is True: # normal

1200 a, b, c, d, i = _plumbTo5(p3.x, p3.y, p3.z, Tun)

1201 return type(p3)(a, b, c), d, i

1202

1203 u3 = p3.negate() if los is False or los is None else _toUvwV3d(los, pov)

1204

1205 a, b, c, T = Tun._ordered4

1206

1207 a2 = a**2 # largest, factored out

1208 b2, p2 = (b**2, T._1e2ab) if b != a else (a2, _1_0)

1209 c2, q2 = (c**2, T._1e2ac) if c != a else (a2, _1_0)

1210

1211 p3 = T._order3d(p3)

1212 u3 = T._order3d(u3).unit() # unit vector, opposing signs

1213

1214 x2, y2, z2 = p3.x2y2z2 # p3.times_(p3).xyz

1215 ux, vy, wz = u3.times_(p3).xyz

1216 u2, v2, w2 = u3.x2y2z2 # u3.times_(u3).xyz

1217

1218 t = (p2 * c2), c2, b2

1219 m = fdot(t, u2, v2, w2) # a2 factored out

1220 if m < EPS0: # zero or near-null LOS vector

1221 raise _ValueError(_near_(_null_))

1222

1223 r = fsumf_(b2 * w2, c2 * v2, -v2 * z2, vy * wz * 2,

1224 -w2 * y2, -u2 * y2 * q2, -u2 * z2 * p2, ux * wz * 2 * p2,

1225 -w2 * x2 * p2, b2 * u2 * q2, -v2 * x2 * q2, ux * vy * 2 * q2)

1226 if r > 0: # a2 factored out

1227 r = sqrt(r) * b * c # == a * a * b * c / a2

1228 elif r < 0: # LOS pointing away from or missing the triaxial

1229 raise _ValueError(_opposite_ if max(ux, vy, wz) > 0 else _outside_)

1230

1231 d = Fdot(t, ux, vy, wz).fadd_(r).fover(m) # -r for antipode, a2 factored out

1232 if d > 0: # POV inside or LOS outside or missing the triaxial

1233 s = fsumf_(_N_1_0, x2 / a2, y2 / b2, z2 / c2) # like _sideOf

1234 raise _ValueError(_outside_ if s > 0 else _inside_)

1235 elif fsum1f_(x2, y2, z2) < d**2: # d past triaxial's center

1236 raise _ValueError(_too_(_distant_))

1237

1238 v = p3.minus(u3.times(d)) # cartesian type(pov) or Vector3d

1239 h = p3.minus(v).length # distance to pov == -d

1240 return T._order3d(v, reverse=True), h, None

1241

1242

1243 def hartzell4(pov, los=False, tri_biax=_WGS84, **name):

1244 '''Compute the intersection of a tri-/biaxial ellipsoid and a Line-Of-Sight

1245 from a Point-Of-View outside.

1246

1247 @arg pov: Point-Of-View outside the tri-/biaxial (C{Cartesian}, L{Ecef9Tuple}

1248 C{LatLon} or L{Vector3d}).

1249 @kwarg los: Line-Of-Sight, I{direction} to the tri-/biaxial (L{Los}, L{Vector3d}),

1250 C{True} for the I{normal, plumb} onto the surface or C{False} or

1251 C{None} to point to the center of the tri-/biaxial.

1252 @kwarg tri_biax: A triaxial (L{Triaxial}, L{Triaxial_}, L{JacobiConformal} or

1253 L{JacobiConformalSpherical}) or biaxial ellipsoid (L{Datum},

1254 L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple} or C{scalar} radius,

1255 conventionally in C{meter}).

1256 @kwarg name: Optional, overriding C{B{name}="hartzell4"} (C{str}).

1257

1258 @return: L{Vector4Tuple}C{(x, y, z, h)} on the tri-/biaxial's surface, with C{h}

1259 the distance from B{C{pov}} to C{(x, y, z)} I{along the} B{C{los}}, all

1260 in C{meter}, conventionally.

1261

1262 @raise TriaxialError: Invalid B{C{pov}} or B{C{pov}} inside the tri-/biaxial or

1263 invalid B{C{los}} or B{C{los}} points outside or away from

1264 the tri-/biaxial.

1265

1266 @raise TypeError: Invalid B{C{tri_biax}}, C{ellipsoid} or C{datum}.

1267

1268 @see: Class L{pygeodesy3.Los}, functions L{pygeodesy.tyr3d} and L{pygeodesy.hartzell}

1269 and U{lookAtSpheroid<https://PyPI.org/project/pymap3d>} and U{"Satellite

1270 Line-of-Sight Intersection with Earth"<https://StephenHartzell.Medium.com/

1271 satellite-line-of-sight-intersection-with-earth-d786b4a6a9b6>}.

1272 '''

1273 if isinstance(tri_biax, Triaxial_):

1274 T = tri_biax

1275 else:

1276 D = tri_biax if isinstance(tri_biax, Datum) else \

1277 _spherical_datum(tri_biax, name__=hartzell4) # _dunder_nameof

1278 T = D.ellipsoid._triaxial

1279 try:

1280 v, h, i = _hartzell3(pov, los, T)

1281 except Exception as x:

1282 raise TriaxialError(pov=pov, los=los, tri_biax=tri_biax, cause=x)

1283 return Vector4Tuple(v.x, v.y, v.z, h, iteration=i, # _dunder_nameof

1284 name=_name__(name, name__=hartzell4))

1285

1286

1287 def _hypot21(x, y, z=0):

1288 '''(INTERNAL) Compute M{x**2 + y**2 + z**2 - 1} with C{max(fabs(x),

1289 fabs(y), fabs(z))} rarely greater than 1.0.

1290 '''

1291 return fsumf_(_1_0, x**2, y**2, (z**2 if z else _0_0), _N_2_0)

1292

1293

1294 def _otherV3d_(x_xyz, y, z, **name):

1295 '''(INTERNAL) Get a Vector3d from C{x_xyz}, C{y} and C{z}.

1296 '''

1297 return Vector3d(x_xyz, y, z, **name) if isscalar(x_xyz) else \

1298 _otherV3d(x_xyz=x_xyz, **name)

1299

1300

1301 def _plumbTo4(x, y, a, b, eps=EPS):

1302 '''(INTERNAL) Nearest point on and distance to a 2-D ellipse, I{unordered}.

1303

1304 @see: Function C{pygeodesy.ellipsoids._plumbTo3} and I{Eberly}'s U{Distance

1305 from a Point to ... an Ellipse ...<https://www.GeometricTools.com/

1306 Documentation/DistancePointEllipseEllipsoid.pdf>}.

1307 '''

1308 if b > a:

1309 b, a, d, i = _plumbTo4(y, x, b, a, eps=eps)

1310 return a, b, d, i

1311

1312 if not (b > 0 and isfinite(a)):

1313 raise _ValueError(a=a, b=b)

1314

1315 i, _a = None, fabs

1316 if y:

1317 if x:

1318 u = _a(x / a)

1319 v = _a(y / b)

1320 g = _hypot21(u, v)

1321 if _a(g) < EPS02: # on the ellipse

1322 a, b, d = x, y, _0_0

1323 else:

1324 r = (b / a)**2

1325 t, i = _rootXd(_1_0 / r, 0, u, 0, v, g, eps)

1326 a = x / (t * r + _1_0)

1327 b = y / (t + _1_0)

1328 d = hypot(x - a, y - b)

1329 else: # x == 0

1330 if y < 0:

1331 b = -b

1332 a, d = x, _a(y - b)

1333

1334 else: # y == 0

1335 n = a * x

1336 d = (a + b) * (a - b)

1337 if d > _a(n): # PYCHOK no cover

1338 r = n / d

1339 a *= r

1340 r = _1_0 - r**2

1341 if r > EPS02:

1342 b *= sqrt(r)

1343 d = hypot(x - a, b)

1344 else:

1345 b = _0_0

1346 d = _a(x - a)

1347 else:

1348 if x < 0:

1349 a = -a

1350 b, d = y, _a(x - a)

1351 return a, b, d, i

1352

1353

1354 def _plumbTo5(x, y, z, Tun, eps=EPS): # MCCABE 19 in .testTriaxials

1355 '''(INTERNAL) Nearest point on and distance to an I{un-/ordered} triaxial.

1356

1357 @see: I{Eberly}'s U{Distance from a Point to ... an Ellipsoid ...<https://

1358 www.GeometricTools.com/Documentation/DistancePointEllipseEllipsoid.pdf>}.

1359 '''

1360 a, b, c, T = Tun._ordered4

1361 if Tun is not T: # T is ordered, Tun isn't

1362 t = T._order3(x, y, z) + (T,)

1363 a, b, c, d, i = _plumbTo5(*t, eps=eps)

1364 return T._order3(a, b, c, reverse=True) + (d, i)

1365

1366 if not (c > 0 and isfinite(a)):

1367 raise _ValueError(a=a, b=b, c=c)

1368

1369 if eps > 0:

1370 val = max(eps * 1e8, EPS)

1371 else: # no validation

1372 val, eps = 0, max(EPS0, -eps)

1373

1374 i, _a = None, fabs

1375 if z:

1376 if y:

1377 if x:

1378 u = _a(x / a)

1379 v = _a(y / b)

1380 w = _a(z / c)

1381 g = _hypot21(u, v, w)

1382 if _a(g) < EPS02: # on the ellipsoid

1383 a, b, c, d = x, y, z, _0_0

1384 else:

1385 r = T._1e2ac # (c / a)**2

1386 s = T._1e2bc # (c / b)**2

1387 t, i = _rootXd(_1_0 / r, _1_0 / s, u, v, w, g, eps)

1388 a = x / (t * r + _1_0)

1389 b = y / (t * s + _1_0)

1390 c = z / (t + _1_0)

1391 d = hypot_(x - a, y - b, z - c)

1392 else: # x == 0

1393 a = x # 0

1394 b, c, d, i = _plumbTo4(y, z, b, c, eps=eps)

1395 elif x: # y == 0

1396 b = y # 0

1397 a, c, d, i = _plumbTo4(x, z, a, c, eps=eps)

1398 else: # x == y == 0

1399 if z < 0:

1400 c = -c

1401 a, b, d = x, y, _a(z - c)

1402

1403 else: # z == 0

1404 t = True

1405 d = T._a2c2 # (a + c) * (a - c)

1406 n = a * x

1407 if d > _a(n):

1408 u = n / d

1409 d = T._b2c2 # (b + c) * (b - c)

1410 n = b * y

1411 if d > _a(n):

1412 v = n / d

1413 n = _hypot21(u, v)

1414 if n < 0:

1415 a *= u

1416 b *= v

1417 c *= sqrt(-n)

1418 d = hypot_(x - a, y - b, c)

1419 t = False

1420 if t:

1421 c = z # signed-0

1422 a, b, d, i = _plumbTo4(x, y, a, b, eps=eps)

1423

1424 if val > 0: # validate

1425 e = T.sideOf(a, b, c, eps=val)

1426 if e: # not near the ellipsoid's surface

1427 raise _ValueError(a=a, b=b, c=c, d=d,

1428 sideOf=e, eps=val)

1429 if d: # angle of delta and normal vector

1430 m = Vector3d(x, y, z).minus_(a, b, c)

1431 if m.euclid > val:

1432 m = m.unit()

1433 n = T.normal3d(a, b, c)

1434 e = n.dot(m) # n.negate().dot(m)

1435 if not isnear1(_a(e), eps1=val):

1436 raise _ValueError(n=n, m=m,

1437 dot=e, eps=val)

1438 return a, b, c, d, i

1439

1440

1441 def _rootXd(r, s, u, v, w, g, eps):

1442 '''(INTERNAL) Robust 2d- or 3d-root finder: 2d- if C{s == v == 0} else 3d-root.

1443

1444 @see: I{Eberly}'s U{Robust Root Finders ...<https://www.GeometricTools.com/

1445 Documentation/DistancePointEllipseEllipsoid.pdf>}.

1446 '''

1447 _1, __2 = _1_0, _0_5

1448 _a, _h21 = fabs, _hypot21

1449

1450 u *= r

1451 v *= s # 0 for 2d-root

1452 t0 = w - _1

1453 t1 = _0_0 if g < 0 else (hypot_(u, w, v) - _1)

1454 # assert t0 <= t1

1455 for i in range(1, _TRIPS): # 48-55

1456 e = _a(t0 - t1)

1457 if e < eps:

1458 break

1459 t = (t0 + t1) * __2

1460 if t in (t0, t1):

1461 break

1462 g = _h21(u / (t + r), w / (t + _1),

1463 (v / (t + s)) if v else 0)

1464 if g > 0:

1465 t0 = t

1466 elif g < 0:

1467 t1 = t

1468 else:

1469 break

1470 else: # PYCHOK no cover

1471 t = Fmt.no_convergence(e, eps)

1472 raise _ValueError(t, txt__=_rootXd)

1473 return t, i

1474

1475

1476 def _sideOf(xyz, abc, eps=EPS):

1477 '''(INTERNAL) Helper for C{_hartzell3}, M{.sideOf} and M{.reverseCartesian}.

1478

1479 @return: M{sum((x / a)**2 for x, a in zip(xyz, abc)) - 1} or C{INT0}.

1480 '''

1481 s = fsumf_(_N_1_0, *((x / a)**2 for x, a in _zip(xyz, abc) if a)) # strict=True

1482 return INT0 if fabs(s) < eps else s

1483

1484

1485 if __name__ == '__main__':

1486

1487 from pygeodesy import printf

1488 from pygeodesy.interns import _COMMA_, _NL_, _NLATvar_

1489

1490 # __doc__ of this file, force all into registery

1491 t = [NN] + Triaxials.toRepr(all=True, asorted=True).split(_NL_)

1492 printf(_NLATvar_.join(i.strip(_COMMA_) for i in t))

1493

1494# **) MIT License

1495#

1496# Copyright (C) 2022-2024 -- mrJean1 at Gmail -- All Rights Reserved.

1497#

1498# Permission is hereby granted, free of charge, to any person obtaining a

1499# copy of this software and associated documentation files (the "Software"),

1500# to deal in the Software without restriction, including without limitation

1501# the rights to use, copy, modify, merge, publish, distribute, sublicense,

1502# and/or sell copies of the Software, and to permit persons to whom the

1503# Software is furnished to do so, subject to the following conditions:

1504#

1505# The above copyright notice and this permission notice shall be included

1506# in all copies or substantial portions of the Software.

1507#

1508# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

1509# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

1510# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

1511# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR

1512# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,

1513# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR

1514# OTHER DEALINGS IN THE SOFTWARE.