coordinate_systems_functions¶
shortfx.fxNumeric.coordinate_systems_functions
¶
Coordinate system conversions.
Conversions between Cartesian and curvilinear coordinate systems from Murray R. Spiegel's Mathematical Handbook of Formulas and Tables: cylindrical, toroidal, parabolic cylindrical, paraboloidal, elliptic cylindrical, oblate/prolate spheroidal, and bipolar coordinates.
Functions¶
bipolar_to_cartesian(u: float, v: float, a: float = 1.0) -> Tuple[float, float]
¶
Converts bipolar (u, v) to Cartesian (x, y).
x = a·sinh(v) / (cosh(v) - cos(u)), y = a·sin(u) / (cosh(v) - cos(u)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
float
|
First bipolar coordinate (u ≠ 2πk). |
required |
v
|
float
|
Second bipolar coordinate. |
required |
a
|
float
|
Scale parameter (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (x, y). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If denominator is zero. |
Example
x, y = bipolar_to_cartesian(math.pi / 2, 1, 1) round(x, 4) 1.3131
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
cartesian_to_cylindrical(x: float, y: float, z: float) -> Tuple[float, float, float]
¶
Converts Cartesian (x, y, z) to cylindrical (rho, phi, z).
rho = sqrt(x² + y²), phi = atan2(y, x), z = z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Cartesian x. |
required |
y
|
float
|
Cartesian y. |
required |
z
|
float
|
Cartesian z. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (rho, phi, z) where phi is in (-π, π]. |
Example
rho, phi, z = cartesian_to_cylindrical(1, 1, 5) (round(rho, 6), round(phi, 6), z) (1.414214, 0.785398, 5)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
cartesian_to_parabolic_cylindrical(x: float, y: float, z: float) -> Tuple[float, float, float]
¶
Converts Cartesian (x, y, z) to parabolic cylindrical (u, v, z).
u = sqrt(sqrt(x² + y²) + x), v = sqrt(sqrt(x² + y²) - x) * sign(y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Cartesian x. |
required |
y
|
float
|
Cartesian y. |
required |
z
|
float
|
Cartesian z. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (u, v, z). |
Example
u, v, z = cartesian_to_parabolic_cylindrical(1.5, 2, 0) (round(u, 4), round(v, 4), z) (2.0, 1.0, 0)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
cylindrical_to_cartesian(rho: float, phi: float, z: float) -> Tuple[float, float, float]
¶
Converts cylindrical (rho, phi, z) to Cartesian (x, y, z).
x = rho cos(phi), y = rho sin(phi), z = z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
float
|
Radial distance (>= 0). |
required |
phi
|
float
|
Azimuthal angle in radians. |
required |
z
|
float
|
Height. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = cylindrical_to_cartesian(2, math.pi / 4, 3) (round(x, 6), round(y, 6), z) (1.414214, 1.414214, 3)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
elliptic_cylindrical_to_cartesian(u: float, v: float, z: float, a: float = 1.0) -> Tuple[float, float, float]
¶
Converts elliptic cylindrical (u, v, z) to Cartesian (x, y, z).
x = a·cosh(u)·cos(v), y = a·sinh(u)·sin(v), z = z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
float
|
Radial-like coordinate (u >= 0). |
required |
v
|
float
|
Angular coordinate in [0, 2π). |
required |
z
|
float
|
Height. |
required |
a
|
float
|
Semi-focal distance (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = elliptic_cylindrical_to_cartesian(1, 0, 0, 1) round(x, 6) 1.543081
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
oblate_spheroidal_to_cartesian(xi: float, eta: float, phi: float, a: float = 1.0) -> Tuple[float, float, float]
¶
Converts oblate spheroidal (ξ, η, φ) to Cartesian (x, y, z).
x = a·cosh(ξ)·cos(η)·cos(φ), y = a·cosh(ξ)·cos(η)·sin(φ), z = a·sinh(ξ)·sin(η).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xi
|
float
|
Radial coordinate (ξ >= 0). |
required |
eta
|
float
|
Angle η in [-π/2, π/2]. |
required |
phi
|
float
|
Azimuthal angle in [0, 2π). |
required |
a
|
float
|
Semi-focal distance (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = oblate_spheroidal_to_cartesian(1, 0, 0, 1) (round(x, 6), round(y, 6), round(z, 6)) (1.543081, 0.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
parabolic_cylindrical_to_cartesian(u: float, v: float, z: float) -> Tuple[float, float, float]
¶
Converts parabolic cylindrical (u, v, z) to Cartesian (x, y, z).
x = (u² - v²)/2, y = uv, z = z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
float
|
First parabolic coordinate. |
required |
v
|
float
|
Second parabolic coordinate (>= 0). |
required |
z
|
float
|
Height. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = parabolic_cylindrical_to_cartesian(2, 1, 0) (x, y, z) (1.5, 2, 0)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
paraboloidal_to_cartesian(u: float, v: float, phi: float) -> Tuple[float, float, float]
¶
Converts paraboloidal (u, v, phi) to Cartesian (x, y, z).
x = u·v·cos(phi), y = u·v·sin(phi), z = (u² - v²)/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
float
|
First paraboloidal coordinate (>= 0). |
required |
v
|
float
|
Second paraboloidal coordinate (>= 0). |
required |
phi
|
float
|
Azimuthal angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = paraboloidal_to_cartesian(1, 1, 0) (x, y, z) (1, 0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
prolate_spheroidal_to_cartesian(xi: float, eta: float, phi: float, a: float = 1.0) -> Tuple[float, float, float]
¶
Converts prolate spheroidal (ξ, η, φ) to Cartesian (x, y, z).
x = a·sinh(ξ)·sin(η)·cos(φ), y = a·sinh(ξ)·sin(η)·sin(φ), z = a·cosh(ξ)·cos(η).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xi
|
float
|
Radial coordinate (ξ >= 0). |
required |
eta
|
float
|
Angle η in [0, π]. |
required |
phi
|
float
|
Azimuthal angle in [0, 2π). |
required |
a
|
float
|
Semi-focal distance (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = prolate_spheroidal_to_cartesian(1, math.pi / 2, 0, 1) (round(x, 6), round(y, 6), round(z, 6)) (1.175201, 0.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/coordinate_systems_functions.py
toroidal_to_cartesian(u: float, v: float, phi: float, a: float = 1.0) -> Tuple[float, float, float]
¶
Converts toroidal (u, v, φ) to Cartesian (x, y, z).
x = a·sinh(v)·cos(φ) / (cosh(v) - cos(u)), y = a·sinh(v)·sin(φ) / (cosh(v) - cos(u)), z = a·sin(u) / (cosh(v) - cos(u)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
float
|
Poloidal angle. |
required |
v
|
float
|
Radial-like coordinate (v > 0). |
required |
phi
|
float
|
Toroidal angle. |
required |
a
|
float
|
Scale parameter (default 1.0). |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
Tuple (x, y, z). |
Example
x, y, z = toroidal_to_cartesian(0, 1, 0, 1) round(x, 4) 2.1640
Complexity: O(1)