trigonometry_functions¶
shortfx.fxNumeric.trigonometry_functions
¶
Numeric Trigonometry Module.
This module provides comprehensive trigonometric and hyperbolic functions, including standard trig functions, inverse functions, and angle conversions.
Key Features
- Basic trigonometric functions (sin, cos, tan)
- Inverse trigonometric functions (arcsin, arccos, arctan)
- Hyperbolic functions (sinh, cosh, tanh) and their inverses
- Reciprocal functions (sec, csc, cot)
- Angle conversions (degrees ↔ radians)
- Distance calculations (hypotenuse)
Example
from shortfx.fxNumeric.trigonometry_functions import sine, degrees_to_radians import math sine(math.pi / 2) 1.0 degrees_to_radians(180) 3.141592653589793
Functions¶
along_track_distance(lat: float, lon: float, path_lat1: float, path_lon1: float, path_lat2: float, path_lon2: float, radius: float = 6371000.0) -> float
¶
Distance along the great-circle path from start to the closest point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Point latitude in degrees. |
required |
lon
|
float
|
Point longitude in degrees. |
required |
path_lat1
|
float
|
Path start latitude. |
required |
path_lon1
|
float
|
Path start longitude. |
required |
path_lat2
|
float
|
Path end latitude. |
required |
path_lon2
|
float
|
Path end longitude. |
required |
radius
|
float
|
Earth radius in meters. |
6371000.0
|
Returns:
| Type | Description |
|---|---|
float
|
Along-track distance in meters. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
along_track_distance(53.2611, -0.7972, 53.3206, -1.7297, 53.1887, 0.1334) > 0 True
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
angle_bisector_length(a: float, b: float, angle: float) -> float
¶
Compute the length of the angle bisector in a triangle.
The bisector from the vertex with included angle divides the opposite side. Length = (2·a·b·cos(angle/2)) / (a + b).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Length of one adjacent side. |
required |
b
|
float
|
Length of the other adjacent side. |
required |
angle
|
float
|
Included angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Length of the angle bisector. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If a or b ≤ 0, or a + b = 0. |
Usage Example
round(angle_bisector_length(3.0, 4.0, 1.0), 4) 3.0089
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
angular_deficiency(n: int) -> float
¶
Compute the angular deficiency of a regular polygon vertex.
angular_deficiency = 2π - n·interior_angle, where interior_angle = (n-2)π/n. Equivalently = 2π·(1 - (n-2)/2) = 4π/n... wait, that's not right for a polyhedron.
For a regular polygon: the exterior angle = 2π/n. This is how much the angle "falls short" of a full turn. Returns the exterior angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of sides (≥ 3). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Exterior angle in radians (= 2π / n). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n is not an integer. |
ValueError
|
If n < 3. |
Usage Example
round(angular_deficiency(6), 4) 1.0472
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
angular_velocity(revolutions: Union[int, float], time_seconds: Union[int, float]) -> float
¶
Computes angular velocity in radians per second.
ω = 2π × revolutions / time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
revolutions
|
Union[int, float]
|
Number of revolutions. |
required |
time_seconds
|
Union[int, float]
|
Time period in seconds (must be positive). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angular velocity in rad/s. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If time_seconds is not positive. |
Example
import math round(angular_velocity(1, 1), 4) 6.2832
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
annular_sector_area(inner_radius: Union[int, float], outer_radius: Union[int, float], angle: Union[int, float]) -> float
¶
Return the area of an annular sector.
A = (θ / 2) · (R² − r²), where θ is in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner_radius
|
Union[int, float]
|
Inner radius (must be ≥ 0). |
required |
outer_radius
|
Union[int, float]
|
Outer radius (must be > inner_radius). |
required |
angle
|
Union[int, float]
|
Central angle in radians (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the annular sector as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If radii or angle constraints are violated. |
Example
round(annular_sector_area(2, 5, math.pi / 2), 4) 16.4934
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
annulus_area(outer_radius: Union[int, float], inner_radius: Union[int, float]) -> float
¶
Calculate the area of an annulus (ring): A = π * (R² - r²).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outer_radius
|
Union[int, float]
|
Outer radius. |
required |
inner_radius
|
Union[int, float]
|
Inner radius. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the annulus. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radii are not positive or inner >= outer. |
Example
round(annulus_area(5, 3), 4) 50.2655
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
arbelos_area(r: Union[int, float], r1: Union[int, float], r2: Union[int, float]) -> float
¶
Return the area of an arbelos.
The arbelos is the region between three semicircles with diameters on the same line where r = r1 + r2.
A = π · r1 · r2 / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
Union[int, float]
|
Radius of the outer semicircle (must be > 0). |
required |
r1
|
Union[int, float]
|
Radius of the first inner semicircle (> 0). |
required |
r2
|
Union[int, float]
|
Radius of the second inner semicircle (> 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the arbelos. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If any radius ≤ 0 or r ≠ r1 + r2. |
Example
round(arbelos_area(5, 3, 2), 6) 9.424778
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
arc_length(radius: float, angle_radians: float) -> float
¶
Compute arc length: r·θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius. |
required |
angle_radians
|
float
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Arc length. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius < 0. |
Usage Example
round(arc_length(5.0, 1.0), 4) 5.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
arccosine(x: float) -> float
¶
Calculates the inverse cosine (arccosine) of a value.
The arccosine function (acos) returns the angle whose cosine is x. The input value x must be between -1 and 1, inclusive, and the returned angle will be in radians, between 0 and pi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value whose arccosine is to be calculated. Must be in the range [-1, 1]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arccosine of the given value in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the range [-1, 1]. |
Example
arccosine(1.0) # acos(1) should be 0 0.0 arccosine(-1.0) # acos(-1) should be pi 3.141592653589793
Cost: O(1), inverse trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
arcsine(x: float) -> float
¶
Calculates the inverse sine (arcsine) of a value.
The arcsine function (asin) returns the angle whose sine is x. The input value x must be between -1 and 1, inclusive, and the returned angle will be in radians, between -pi/2 and pi/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value whose arcsine is to be calculated. Must be in the range [-1, 1]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arcsine of the given value in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the range [-1, 1]. |
Example
arcsine(1.0) # asin(1) should be pi/2 1.5707963267948966 arcsine(0.0) 0.0
Cost: O(1), inverse trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
arctangent(x: float) -> float
¶
Calculates the inverse tangent (arctangent) of a value.
The arctangent function (atan) returns the angle whose tangent is x. The input value x can be any real number, and the returned angle will be in radians, between -pi/2 and pi/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value whose arctangent is to be calculated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arctangent of the given value in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
arctangent(1.0) # atan(1) should be pi/4 0.7853981633974483 arctangent(0.0) 0.0
Cost: O(1), inverse trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
arctangent2(y: float, x: float) -> float
¶
Calculates the inverse tangent of y/x using the signs of both arguments to determine the correct quadrant.
The arctangent2 function (atan2) is useful for converting Cartesian coordinates (x, y) to polar coordinates (r, theta). The returned angle is in radians, between -pi and pi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
float
|
The y-coordinate. |
required |
x
|
float
|
The x-coordinate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The arctangent of y/x in radians, considering the quadrant. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x or y are not floats or integers. |
Example
arctangent2(1, 1) # atan2(1, 1) should be pi/4 0.7853981633974483 arctangent2(-1, 1) # atan2(-1, 1) should be -pi/4 -0.7853981633974483 arctangent2(1, -1) # atan2(1, -1) should be 3*pi/4 2.356194490192345
Cost: O(1), atan2 function for quadrant handling.
Source code in shortfx/fxNumeric/trigonometry_functions.py
bearing(lat1: float, lon1: float, lat2: float, lon2: float) -> float
¶
Computes the initial bearing (forward azimuth) between two GPS coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat1
|
float
|
Latitude of point 1 in decimal degrees. |
required |
lon1
|
float
|
Longitude of point 1 in decimal degrees. |
required |
lat2
|
float
|
Latitude of point 2 in decimal degrees. |
required |
lon2
|
float
|
Longitude of point 2 in decimal degrees. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Initial bearing in degrees (0–360). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
round(bearing(40.4168, -3.7038, 48.8566, 2.3522), 1) # Madrid→Paris 24.8
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cartesian_to_cylindrical(x: float, y: float, z: float) -> tuple[float, float, float]
¶
Convert Cartesian coordinates (x, y, z) to cylindrical (ρ, φ, z).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X coordinate. |
required |
y
|
float
|
Y coordinate. |
required |
z
|
float
|
Z coordinate. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
Tuple (rho, phi, z) where phi is in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
cartesian_to_cylindrical(1.0, 0.0, 5.0) (1.0, 0.0, 5.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cartesian_to_polar(x: float, y: float) -> tuple[float, float]
¶
Convert Cartesian coordinates (x, y) to polar (r, θ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X coordinate. |
required |
y
|
float
|
Y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple (r, theta) where theta is in radians [-π, π]. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
cartesian_to_polar(1.0, 0.0) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cartesian_to_spherical(x: float, y: float, z: float) -> tuple[float, float, float]
¶
Convert Cartesian coordinates (x, y, z) to spherical (r, θ, φ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X coordinate. |
required |
y
|
float
|
Y coordinate. |
required |
z
|
float
|
Z coordinate. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
Tuple (r, theta, phi) in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
cartesian_to_spherical(0.0, 0.0, 1.0) (1.0, 0.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
chord_length(radius: float, angle_radians: float) -> float
¶
Compute the chord length: 2r·sin(θ/2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the circle. |
required |
angle_radians
|
float
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Chord length. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius < 0. |
Usage Example
round(chord_length(1.0, 1.0), 4) 0.9589
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
circular_arc_length(radius: Union[int, float], angle: float) -> float
¶
Computes the arc length of a circle given radius and central angle.
arc = r × θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the circle (positive). |
required |
angle
|
float
|
Central angle in radians (>= 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The arc length. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius <= 0 or angle < 0. |
Example
import math round(circular_arc_length(5, math.pi / 2), 4) 7.854
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
circular_ring_area(outer_radius: Union[int, float], inner_radius: Union[int, float]) -> float
¶
Calculate the area of a circular ring (same as annulus): A = π(R² - r²).
This is an alias for annulus_area using a more intuitive name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outer_radius
|
Union[int, float]
|
Outer radius. |
required |
inner_radius
|
Union[int, float]
|
Inner radius. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the ring. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radii not positive or inner ≥ outer. |
Example
round(circular_ring_area(5, 3), 4) 50.2655
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
circular_sector_area(radius: Union[int, float], angle: Union[int, float]) -> float
¶
Calculate the area of a circular sector A = ½·r²·θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the circle. |
required |
angle
|
Union[int, float]
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the sector. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius not positive or angle not in (0, 2π]. |
Example
import math round(circular_sector_area(5, math.pi / 2), 4) 19.635
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
circular_segment_area(radius: Union[int, float], angle: Union[int, float]) -> float
¶
Calculate the area of a circular segment.
A = (r²/2) · (θ - sin(θ)) where θ is the central angle in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the circle. |
required |
angle
|
Union[int, float]
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the circular segment. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius is not positive or angle not in (0, 2π]. |
Example
import math round(circular_segment_area(5, math.pi), 4) 39.2699
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
circular_segment_chord(radius: Union[int, float], angle: Union[int, float]) -> float
¶
Return the chord length of a circular segment.
Chord = 2 · r · sin(θ / 2), where θ is the central angle in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the circle (must be > 0). |
required |
angle
|
Union[int, float]
|
Central angle in radians (must be in (0, 2π]). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Chord length as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If radius ≤ 0 or angle out of range. |
Example
round(circular_segment_chord(5, math.pi / 2), 6) 7.071068
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
circular_segment_height(radius: float, angle_radians: float) -> float
¶
Compute the height of a circular segment (sagitta).
h = r(1 - cos(θ/2))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the circle. |
required |
angle_radians
|
float
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Height (sagitta) of the segment. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius < 0. |
Usage Example
round(circular_segment_height(10.0, 1.0), 4) 1.2242
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cone_lateral_area(radius: Union[int, float], slant_height: Union[int, float]) -> float
¶
Calculate the lateral surface area of a cone: A = π·r·l.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Base radius. |
required |
slant_height
|
Union[int, float]
|
Slant height. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Lateral surface area. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If dimensions are not positive. |
Example
round(cone_lateral_area(3, 5), 4) 47.1239
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cone_slant_height(radius: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the slant height of a cone l = √(r² + h²).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Base radius. |
required |
height
|
Union[int, float]
|
Vertical height. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Slant height. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If inputs are not positive. |
Example
cone_slant_height(3, 4) 5.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cosecant(angle_radians: float) -> float
¶
Calculates the cosecant of an angle. Cosec(X) = 1 / Sin(X)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The cosecant of the given angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If sine(angle_radians) is zero (cosecant is undefined). |
Example
round(cosecant(math.pi / 2), 10) # cosec(90 degrees) 1.0 round(cosecant(3 * math.pi / 2), 10) # cosec(270 degrees) -1.0
Cost: O(1), derived trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
cosine(angle_radians: float) -> float
¶
Calculates the cosine of an angle.
The cosine function (cos) is one of the primary trigonometric functions. It relates the ratio of the length of the adjacent side to the length of the hypotenuse in a right-angled triangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The cosine of the given angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
cosine(0) # cos(0 degrees) 1.0 cosine(math.pi) # cos(180 degrees) -1.0
Cost: O(1), standard trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
cotangent(angle_radians: float) -> float
¶
Calculates the cotangent of an angle. Cotan(X) = 1 / Tan(X)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The cotangent of the given angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If tangent(angle_radians) is zero or undefined (cotangent is undefined). |
Example
round(cotangent(math.pi / 4), 10) # cot(45 degrees) 1.0
cotangent(0) would raise ValueError¶
Cost: O(1), derived trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
coversine(angle_radians: float) -> float
¶
Computes the coversine: coversin(x) = 1 - sin(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Coversine of the angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not numeric. |
Example
coversine(0) 1.0 round(coversine(math.pi / 2), 10) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cross_track_distance(lat: float, lon: float, path_lat1: float, path_lon1: float, path_lat2: float, path_lon2: float, radius: float = 6371000.0) -> float
¶
Perpendicular distance from a point to a great-circle path (meters).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Point latitude in degrees. |
required |
lon
|
float
|
Point longitude in degrees. |
required |
path_lat1
|
float
|
Path start latitude. |
required |
path_lon1
|
float
|
Path start longitude. |
required |
path_lat2
|
float
|
Path end latitude. |
required |
path_lon2
|
float
|
Path end longitude. |
required |
radius
|
float
|
Earth radius in meters (default 6 371 000). |
6371000.0
|
Returns:
| Type | Description |
|---|---|
float
|
Signed cross-track distance in meters. Positive = left of path. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
abs(cross_track_distance(53.2611, -0.7972, 53.3206, -1.7297, 53.1887, 0.1334)) < 500 True
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 | |
cyclic_polygon_radius(side_length: Union[int, float], n_sides: int) -> float
¶
Return the circumradius of a regular polygon.
R = a / (2 · sin(π / n)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
side_length
|
Union[int, float]
|
Length of one side (must be > 0). |
required |
n_sides
|
int
|
Number of sides (must be ≥ 3). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Circumscribed circle radius as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If side_length is not numeric or n_sides not int. |
ValueError
|
If side_length ≤ 0 or n_sides < 3. |
Example
round(cyclic_polygon_radius(1, 6), 6) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cylinder_lateral_area(radius: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the lateral surface area of a cylinder: A = 2·π·r·h.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Base radius. |
required |
height
|
Union[int, float]
|
Height of the cylinder. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Lateral surface area. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If dimensions are not positive. |
Example
round(cylinder_lateral_area(3, 5), 4) 94.2478
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
cylindrical_to_cartesian(rho: float, phi: float, z: float) -> tuple[float, float, float]
¶
Convert cylindrical coordinates (ρ, φ, z) to Cartesian (x, y, z).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
float
|
Radial distance in xy-plane. |
required |
phi
|
float
|
Azimuthal angle in radians. |
required |
z
|
float
|
Height. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
Tuple (x, y, z). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
cylindrical_to_cartesian(1.0, 0.0, 5.0) (1.0, 0.0, 5.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
damped_oscillation(amplitude: float, decay: float, frequency: float, t: float) -> float
¶
Evaluate a damped oscillation: A·e^(-γt)·cos(2πft).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amplitude
|
float
|
Initial amplitude A. |
required |
decay
|
float
|
Decay constant γ (≥ 0). |
required |
frequency
|
float
|
Frequency f in Hz. |
required |
t
|
float
|
Time in seconds. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Oscillation value at time t. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If decay < 0. |
Usage Example
round(damped_oscillation(1.0, 0.5, 1.0, 1.0), 4) 0.6065
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
degrees_to_radians(degrees: float) -> float
¶
Converts an angle from degrees to radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degrees
|
float
|
The angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The equivalent angle in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
degrees_to_radians(180) 3.141592653589793 degrees_to_radians(90) 1.5707963267948966
Cost: O(1), simple angle conversion.
Source code in shortfx/fxNumeric/trigonometry_functions.py
destination_point(lat: float, lon: float, brng: float, distance_km: float) -> tuple
¶
Computes the destination point given an origin, bearing, and distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Origin latitude in decimal degrees. |
required |
lon
|
float
|
Origin longitude in decimal degrees. |
required |
brng
|
float
|
Bearing in degrees (0–360). |
required |
distance_km
|
float
|
Distance to travel in kilometres. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple (latitude, longitude) of the destination. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If distance_km is negative. |
Example
dlat, dlon = destination_point(40.4168, -3.7038, 24.8, 1000) round(dlat, 1) 48.3
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
distance_point_to_line(px: float, py: float, x1: float, y1: float, x2: float, y2: float) -> float
¶
Computes the perpendicular distance from a point to a line segment.
The line is defined by two points (x1, y1)–(x2, y2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
px
|
float
|
X-coordinate of the point. |
required |
py
|
float
|
Y-coordinate of the point. |
required |
x1
|
float
|
X of first endpoint. |
required |
y1
|
float
|
Y of first endpoint. |
required |
x2
|
float
|
X of second endpoint. |
required |
y2
|
float
|
Y of second endpoint. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Perpendicular distance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If the two endpoints are identical. |
Example
distance_point_to_line(1, 1, 0, 0, 2, 0) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
ellipse_area(semi_major: Union[int, float], semi_minor: Union[int, float]) -> float
¶
Calculate the area of an ellipse: A = π * a * b.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
semi_major
|
Union[int, float]
|
Semi-major axis length. |
required |
semi_minor
|
Union[int, float]
|
Semi-minor axis length. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the ellipse. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If axes are not positive. |
Example
round(ellipse_area(5, 3), 4) 47.1239
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
ellipse_circumference_approx(a: Union[int, float], b: Union[int, float]) -> float
¶
Approximate the circumference of an ellipse using Ramanujan's formula.
C ≈ π · (3(a+b) - √((3a+b)(a+3b)))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Semi-major axis. |
required |
b
|
Union[int, float]
|
Semi-minor axis. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Approximate circumference. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If axes are not positive. |
Example
round(ellipse_circumference_approx(5, 3), 4) 25.5268
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
ellipse_perimeter(semi_major: Union[int, float], semi_minor: Union[int, float]) -> float
¶
Approximate the perimeter of an ellipse using Ramanujan's formula.
P ≈ π * [3(a+b) - √((3a+b)(a+3b))]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
semi_major
|
Union[int, float]
|
Semi-major axis length. |
required |
semi_minor
|
Union[int, float]
|
Semi-minor axis length. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Approximate perimeter of the ellipse. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If axes are not positive. |
Example
round(ellipse_perimeter(5, 3), 4) 25.5268
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
ellipsoid_volume(a: Union[int, float], b: Union[int, float], c: Union[int, float]) -> float
¶
Calculate the volume of an ellipsoid V = (4/3)·π·a·b·c.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Semi-axis length along x. |
required |
b
|
Union[int, float]
|
Semi-axis length along y. |
required |
c
|
Union[int, float]
|
Semi-axis length along z. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the ellipsoid. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If any axis is not positive. |
Example
import math round(ellipsoid_volume(3, 4, 5), 4) 251.3274
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
epicycloid_arc_length(big_r: Union[int, float], small_r: Union[int, float]) -> float
¶
Return the total arc length of one full epicycloid.
L = 8 · R · r / (R + r), scaled by the outer radius. Actually L = 8 · (R + r) · sin(π·r/(R+r)) for the general case — but for a complete epicycloid (integer ratio):
L_total = 8 · R · (R + r) / R - simplifies when R/r is integer. Standard formula: L = 8r(R + r)/R.
General formula for total length of a complete epicycloid: L = 8 · r · (R + r) / R.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
big_r
|
Union[int, float]
|
Radius of the fixed circle (must be > 0). |
required |
small_r
|
Union[int, float]
|
Radius of the rolling circle (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Total arc length of the epicycloid. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If any argument ≤ 0. |
Example
epicycloid_arc_length(5, 1) 9.6
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
excosecant(angle_radians: float) -> float
¶
Computes the excosecant: excsc(x) = csc(x) - 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
Angle in radians (sin(x) != 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Excosecant of the angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not numeric. |
ValueError
|
If sin(angle) is zero. |
Example
round(excosecant(math.pi / 2), 10) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
exsecant(angle_radians: float) -> float
¶
Computes the exsecant: exsec(x) = sec(x) - 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
Angle in radians (cos(x) != 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Exsecant of the angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not numeric. |
ValueError
|
If cos(angle) is zero. |
Example
exsecant(0) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
frustum_lateral_area(r1: Union[int, float], r2: Union[int, float], slant_height: Union[int, float]) -> float
¶
Return the lateral surface area of a conical frustum.
A = π · (r₁ + r₂) · l.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r1
|
Union[int, float]
|
Radius of the smaller base (must be ≥ 0). |
required |
r2
|
Union[int, float]
|
Radius of the larger base (must be ≥ 0). |
required |
slant_height
|
Union[int, float]
|
Slant height of the frustum (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Lateral surface area as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If r1 or r2 is negative, or slant_height ≤ 0. |
Example
round(frustum_lateral_area(2, 4, 5), 4) 94.2478
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
frustum_volume(radius_top: Union[int, float], radius_bottom: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the volume of a conical frustum.
V = (π·h / 3) · (R² + R·r + r²)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius_top
|
Union[int, float]
|
Top radius. |
required |
radius_bottom
|
Union[int, float]
|
Bottom radius. |
required |
height
|
Union[int, float]
|
Height of the frustum. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If any dimension is not positive. |
Example
round(frustum_volume(2, 4, 5), 4) 146.608
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
geodesic_area(vertices: list[tuple[float, float]]) -> float
¶
Approximate area of a polygon on a sphere using the spherical excess formula.
Vertices are (latitude, longitude) pairs in degrees. Uses a
mean Earth radius of 6371008.8 m.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
list[tuple[float, float]]
|
List of |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area in square metres (absolute value). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If vertices is not a list of tuples. |
ValueError
|
If fewer than 3 vertices. |
Example
area = geodesic_area([(0, 0), (0, 1), (1, 1), (1, 0)]) round(area / 1e6) 12309
Complexity: O(n)
Source code in shortfx/fxNumeric/trigonometry_functions.py
gudermannian(x: Union[int, float]) -> float
¶
Compute the Gudermannian function: gd(x) = 2 * atan(tanh(x/2)).
Links circular and hyperbolic functions without using complex numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[int, float]
|
Input value in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Gudermannian of x, in the range (-pi/2, pi/2). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
Example
import math round(gudermannian(1), 6) 0.865769
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
hacoverversine(angle_radians: float) -> float
¶
Compute the hacoversed versine (hacoverversine) = (1 + sin(θ))/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Hacoverversine value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If angle_radians is not numeric. |
Usage Example
round(hacoverversine(0.5), 4) 0.7397
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
haversine_angle(theta: Union[int, float]) -> float
¶
Compute the haversine of an angle: hav(θ) = sin²(θ/2).
The haversine function is used in navigation formulas for computing great-circle distances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
Union[int, float]
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Haversine value in [0, 1]. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If theta is not numeric. |
Example
import math haversine_angle(math.pi) 1.0 haversine_angle(0) 0.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float
¶
Calculates the great-circle distance between two points on Earth.
Uses the Haversine formula. Input coordinates are in decimal degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat1
|
float
|
Latitude of point 1 in degrees. |
required |
lon1
|
float
|
Longitude of point 1 in degrees. |
required |
lat2
|
float
|
Latitude of point 2 in degrees. |
required |
lon2
|
float
|
Longitude of point 2 in degrees. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Distance in kilometers. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
round(haversine_distance(40.4168, -3.7038, 48.8566, 2.3522), 0) 1053.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
haversine_trig(angle_radians: float) -> float
¶
Computes the haversine: hav(x) = (1 - cos(x)) / 2 = sin^2(x/2).
Fundamental to the haversine formula for great-circle distances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Haversine of the angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not numeric. |
Example
haversine_trig(0) 0.0 round(haversine_trig(math.pi), 10) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
herons_formula(a: Union[int, float], b: Union[int, float], c: Union[int, float]) -> float
¶
Computes the area of a triangle from its three side lengths.
Area = √(s(s−a)(s−b)(s−c)) where s = (a+b+c)/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Length of side a (positive). |
required |
b
|
Union[int, float]
|
Length of side b (positive). |
required |
c
|
Union[int, float]
|
Length of side c (positive). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The area of the triangle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If sides are non-positive or do not form a valid triangle. |
Example
herons_formula(3, 4, 5) 6.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
hexagon_area(side: Union[int, float]) -> float
¶
Calculate the area of a regular hexagon.
A = (3√3/2)·s²
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
side
|
Union[int, float]
|
Side length. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the hexagon. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If input is not numeric. |
ValueError
|
If side is not positive. |
Example
round(hexagon_area(4), 4) 41.5692
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_cosecant(x: float) -> float
¶
Calculates the hyperbolic cosecant of a value. HCosec(X) = 2 / (Exp(X) - Exp(-X)) = 1 / HSin(X)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cosecant of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If x is 0 (hyperbolic cosecant is undefined). |
Example
round(hyperbolic_cosecant(1), 5) 0.85091
hyperbolic_cosecant(0) would raise ValueError¶
Cost: O(1), derived hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_cosine(x: float) -> float
¶
Calculates the hyperbolic cosine of a value.
The hyperbolic cosine function (cosh) is a hyperbolic analogue of the trigonometric cosine function. It is defined as (e^x + e^-x) / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cosine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
hyperbolic_cosine(0) 1.0 round(hyperbolic_cosine(1), 5) 1.54308
Cost: O(1), standard hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_cosine_derived(x: float) -> float
¶
Calculates the hyperbolic cosine of a value using its exponential definition. HCos(X) = (Exp(X) + Exp(-X)) / 2 Equivalent to math.cosh(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cosine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
hyperbolic_cosine_derived(0) 1.0 round(hyperbolic_cosine_derived(1), 5) 1.54308
Cost: O(1), hyperbolic function derived from exponentials.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_cotangent(x: float) -> float
¶
Calculates the hyperbolic cotangent of a value. HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X)) = 1 / HTan(X)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic cotangent of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If x is 0 (hyperbolic cotangent is undefined). |
Example
round(hyperbolic_cotangent(1), 5) 1.31303
hyperbolic_cotangent(0) would raise ValueError¶
Cost: O(1), derived hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_distance(x1: float, y1: float, x2: float, y2: float) -> float
¶
Compute the hyperbolic distance in the Poincaré half-plane model.
d = arccosh(1 + ((x2-x1)² + (y2-y1)²) / (2·y1·y2))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1, y1
|
First point (y1 > 0). |
required | |
x2, y2
|
Second point (y2 > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Hyperbolic distance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If y1 or y2 ≤ 0. |
Usage Example
round(hyperbolic_distance(0, 1, 0, 2), 4) 0.6931
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_secant(x: float) -> float
¶
Calculates the hyperbolic secant of a value. HSec(X) = 2 / (Exp(X) + Exp(-X)) = 1 / HCos(X)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic secant of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the denominator is zero (which only happens for specific complex values, not for real numbers). |
Example
round(hyperbolic_secant(0), 10) 1.0 round(hyperbolic_secant(1), 5) 0.64805
Cost: O(1), derived hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_sine(x: float) -> float
¶
Calculates the hyperbolic sine of a value.
The hyperbolic sine function (sinh) is a hyperbolic analogue of the trigonometric sine function. It is defined as (e^x - e^-x) / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic sine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
hyperbolic_sine(0) 0.0 round(hyperbolic_sine(1), 5) 1.1752
Cost: O(1), standard hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_sine_derived(x: float) -> float
¶
Calculates the hyperbolic sine of a value using its exponential definition. HSin(X) = (Exp(X) - Exp(-X)) / 2 Equivalent to math.sinh(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic sine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
hyperbolic_sine_derived(0) 0.0 round(hyperbolic_sine_derived(1), 5) 1.17520
Cost: O(1), hyperbolic function derived from exponentials.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_tangent(x: float) -> float
¶
Calculates the hyperbolic tangent of a value.
The hyperbolic tangent function (tanh) is a hyperbolic analogue of the trigonometric tangent function. It is defined as sinh(x) / cosh(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic tangent of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
hyperbolic_tangent(0) 0.0 round(hyperbolic_tangent(1), 5) 0.76159
Cost: O(1), standard hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hyperbolic_tangent_derived(x: float) -> float
¶
Calculates the hyperbolic tangent of a value using its exponential definition. HTan(X) = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X)) Equivalent to math.tanh(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hyperbolic tangent of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the denominator is zero (which only happens for specific complex values, not for real numbers). |
Example
hyperbolic_tangent_derived(0) 0.0 round(hyperbolic_tangent_derived(1), 5) 0.76159
Cost: O(1), hyperbolic function derived from exponentials.
Source code in shortfx/fxNumeric/trigonometry_functions.py
hypocycloid_arc_length(big_r: Union[int, float], small_r: Union[int, float]) -> float
¶
Return the total arc length of one full hypocycloid.
L = 8 · r · (R − r) / R.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
big_r
|
Union[int, float]
|
Radius of the fixed circle (must be > 0). |
required |
small_r
|
Union[int, float]
|
Radius of the rolling circle (0 < r < R). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Total arc length of the hypocycloid. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If big_r ≤ 0, small_r ≤ 0, or small_r ≥ big_r. |
Example
hypocycloid_arc_length(5, 1) 6.4
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
hypotenuse(x: float, y: float) -> float
¶
Calculates the Euclidean norm, sqrt(xx + yy). This is the length of the hypotenuse of a right-angled triangle with legs of length x and y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The length of the first leg. |
required |
y
|
float
|
The length of the second leg. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The length of the hypotenuse. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x or y are not floats or integers. |
Example
hypotenuse(3, 4) 5.0 hypotenuse(5, 12) 13.0
Cost: O(1), hypotenuse calculation using math.hypot.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inscribed_angle(central_angle: Union[int, float]) -> float
¶
Calculate the inscribed angle from a central angle.
An inscribed angle is half of the central angle that subtends the same arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_angle
|
Union[int, float]
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Inscribed angle in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If input is not numeric. |
ValueError
|
If central_angle not in (0, 2π]. |
Example
import math inscribed_angle(math.pi) 1.5707963267948966
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
intermediate_point(lat1: float, lon1: float, lat2: float, lon2: float, fraction: float) -> tuple[float, float]
¶
Find a point at a given fraction along the great-circle path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat1
|
float
|
Start latitude in degrees. |
required |
lon1
|
float
|
Start longitude in degrees. |
required |
lat2
|
float
|
End latitude in degrees. |
required |
lon2
|
float
|
End longitude in degrees. |
required |
fraction
|
float
|
Fraction along the path (0.0 = start, 1.0 = end). |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If fraction is not in [0, 1]. |
Example
lat, lon = intermediate_point(0, 0, 0, 10, 0.5) round(lon, 1) 5.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 | |
inverse_cosecant(x: float) -> float
¶
Calculates the inverse cosecant (arccosec) of a value. Arccosec(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * (2 * Atn(1)) Note: In Python, math.asin(1/x) is the direct equivalent for arccosec(x). The provided formula is a common way to derive it using arctangent. Domain: |x| >= 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value whose inverse cosecant is to be calculated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse cosecant of the given value in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the domain |x| >= 1 or if x*x - 1 is negative (square root of negative number). |
Example
round(inverse_cosecant(1.0), 10) # arccosec(1) should be pi/2 1.5707963268 round(inverse_cosecant(-1.0), 10) # arccosec(-1) should be -pi/2 -1.5707963268 round(inverse_cosecant(2.0), 10) # arccosec(2) should be pi/6 (30 degrees) 0.5235987756
Cost: O(1), inverse trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_cotangent(x: float) -> float
¶
Calculates the inverse cotangent (arccotan) of a value. Arccotan(X) = Atn(X) + 2 * Atn(1) (This formula is for arccot(x) in (0, pi)) Note: Python's math.atan(x) returns an angle in (-pi/2, pi/2). A common definition of arccot(x) is atan(1/x) for x != 0, and pi/2 for x=0. Or, math.atan2(1, x) covers all cases and quadrants for arccot(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value whose inverse cotangent is to be calculated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse cotangent of the given value in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
round(inverse_cotangent(1.0), 10) # arccot(1) should be pi/4 (0.785...) 0.7853981634 round(inverse_cotangent(0.0), 10) # arccot(0) should be pi/2 1.5707963268 round(inverse_cotangent(-1.0), 10) # arccot(-1) should be 3pi/4 2.3561944902
Cost: O(1), inverse trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_gudermannian(x: Union[int, float]) -> float
¶
Compute the inverse Gudermannian: gd⁻¹(x) = 2 * atanh(tan(x/2)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[int, float]
|
Input value in (-pi/2, pi/2). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Inverse Gudermannian of x. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
ValueError
|
If x is not in (-pi/2, pi/2). |
Example
round(inverse_gudermannian(0.865769), 4) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_cosecant(x: float) -> float
¶
Calculates the inverse hyperbolic cosecant (arccosech) of a value. HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X) Domain: All real numbers except 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must not be 0. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic cosecant of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is 0 (division by zero). |
Example
round(inverse_hyperbolic_cosecant(1.0), 10) 0.881373587 round(inverse_hyperbolic_cosecant(-1.0), 10) -0.881373587
Cost: O(1), inverse hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_cosine(x: float) -> float
¶
Calculates the inverse hyperbolic cosine (arccosh) of a value.
The inverse hyperbolic cosine function (acosh) returns the value whose hyperbolic cosine is x. The input value x must be >= 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must be greater than or equal to 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic cosine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is less than 1. |
Example
inverse_hyperbolic_cosine(1.0) 0.0 round(inverse_hyperbolic_cosine(1.54308), 5) # approximately acosh(cosh(1)) 1.0
Cost: O(1), inverse hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_cosine_derived(x: float) -> float
¶
Calculates the inverse hyperbolic cosine (arccosh) of a value. HArccos(X) = Log(X + Sqr(X * X - 1)) Equivalent to math.acosh(x). Domain: X >= 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must be >= 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic cosine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is less than 1. |
Example
inverse_hyperbolic_cosine_derived(1.0) 0.0 round(inverse_hyperbolic_cosine_derived(2.0), 10) 1.3169578969
Cost: O(1), inverse hyperbolic function derived from logarithm.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_cotangent(x: float) -> float
¶
Calculates the inverse hyperbolic cotangent (arccotanh) of a value. HArccotan(X) = Log((X + 1) / (X - 1)) / 2 Domain: |X| > 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must be |X| > 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic cotangent of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the domain |X| > 1 or if X is 1 or -1 (division by zero). |
Example
round(inverse_hyperbolic_cotangent(2.0), 10) 0.5493061443 round(inverse_hyperbolic_cotangent(-2.0), 10) -0.5493061443
Cost: O(1), inverse hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_secant(x: float) -> float
¶
Calculates the inverse hyperbolic secant (arcsech) of a value. HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X) Domain: 0 < X <= 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must be in the range (0, 1]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic secant of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the domain (0, 1]. Also if -X*X + 1 is negative (square root of negative number) or if X is zero (division by zero). |
Example
round(inverse_hyperbolic_secant(1.0), 10) 0.0 round(inverse_hyperbolic_secant(0.5), 10) 1.3169578969
Cost: O(1), inverse hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_sine(x: float) -> float
¶
Calculates the inverse hyperbolic sine (arcsinh) of a value.
The inverse hyperbolic sine function (asinh) returns the value whose hyperbolic sine is x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic sine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
inverse_hyperbolic_sine(0) 0.0 round(inverse_hyperbolic_sine(1.1752), 5) # approximately asinh(sinh(1)) 1.0
Cost: O(1), inverse hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_sine_derived(x: float) -> float
¶
Calculates the inverse hyperbolic sine (arcsinh) of a value. HArcsin(X) = Log(X + Sqr(X * X + 1)) Equivalent to math.asinh(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic sine of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
inverse_hyperbolic_sine_derived(0) 0.0 round(inverse_hyperbolic_sine_derived(1), 10) 0.881373587
Cost: O(1), inverse hyperbolic function derived from logarithm.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_tangent(x: float) -> float
¶
Calculates the inverse hyperbolic tangent (arctanh) of a value.
The inverse hyperbolic tangent function (atanh) returns the value whose hyperbolic tangent is x. The input value x must be between -1 and 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must be in the range (-1, 1). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic tangent of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the range (-1, 1). |
Example
inverse_hyperbolic_tangent(0) 0.0 round(inverse_hyperbolic_tangent(0.76159), 5) # approximately atanh(tanh(1)) 1.0
Cost: O(1), inverse hyperbolic function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_hyperbolic_tangent_derived(x: float) -> float
¶
Calculates the inverse hyperbolic tangent (arctanh) of a value. HArctan(X) = Log((1 + X) / (1 - X)) / 2 Equivalent to math.atanh(x). Domain: -1 < X < 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value. Must be between -1 and 1 (exclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse hyperbolic tangent of the given value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the range (-1, 1). |
Example
inverse_hyperbolic_tangent_derived(0) 0.0 round(inverse_hyperbolic_tangent_derived(0.5), 10) 0.5493061443
Cost: O(1), inverse hyperbolic function derived from logarithm.
Source code in shortfx/fxNumeric/trigonometry_functions.py
inverse_secant(x: float) -> float
¶
Calculates the inverse secant (arcsec) of a value. Arcsec(X) = Atn(X / Sqr(X * X - 1)) + Sgn((X) - 1) * (2 * Atn(1)) Note: In Python, math.acos(1/x) is the direct equivalent for arcsec(x). The provided formula is a common way to derive it using arctangent. Domain: |x| >= 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The value whose inverse secant is to be calculated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The inverse secant of the given value in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the input value x is outside the domain |x| >= 1 or if x*x - 1 is negative (square root of negative number). |
Example
round(inverse_secant(1.0), 10) # arcsec(1) should be 0 0.0 round(inverse_secant(-1.0), 10) # arcsec(-1) should be pi 3.1415926536 round(inverse_secant(2.0), 10) # arcsec(2) should be pi/3 (60 degrees) 1.0471975512
Cost: O(1), inverse trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
law_of_cosines_angle(a: Union[int, float], b: Union[int, float], c: Union[int, float]) -> float
¶
Finds the angle opposite side c using the law of cosines.
cos(C) = (a² + b² − c²) / (2ab).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Length of side a (positive). |
required |
b
|
Union[int, float]
|
Length of side b (positive). |
required |
c
|
Union[int, float]
|
Length of side c (positive). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle C in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If sides are non-positive or do not form a valid triangle. |
Example
import math round(law_of_cosines_angle(3, 4, 5), 4) 1.5708
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
law_of_cosines_side(a: Union[int, float], b: Union[int, float], angle_c: float) -> float
¶
Finds the third side of a triangle using the law of cosines.
c² = a² + b² − 2ab·cos(C).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Length of side a (positive). |
required |
b
|
Union[int, float]
|
Length of side b (positive). |
required |
angle_c
|
float
|
Angle opposite to the unknown side, in radians (0, π). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Length of the unknown side c. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If sides are non-positive or angle is out of (0, π). |
Example
import math round(law_of_cosines_side(5, 7, math.pi / 3), 4) 6.2450
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
law_of_sines(a: Union[int, float], angle_a: float, angle_b: float) -> float
¶
Finds side b using the law of sines: b = a × sin(B) / sin(A).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Length of side a (positive). |
required |
angle_a
|
float
|
Angle opposite side a in radians (0 < angle < π). |
required |
angle_b
|
float
|
Angle opposite the unknown side b in radians (0 < angle < π). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Length of side b. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If a <= 0, angles not in (0, π), or angles sum > π. |
Example
import math round(law_of_sines(10, math.radians(30), math.radians(45)), 4) 14.1421
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
lens_area(radius: Union[int, float], distance: Union[int, float]) -> float
¶
Calculate the area of intersection of two equal circles (lens/vesica).
When two circles of radius r have centres distance d apart (d < 2r), the lens area is 2r²·arccos(d/(2r)) - (d/2)·√(4r² - d²).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of both circles. |
required |
distance
|
Union[int, float]
|
Distance between centres (must be < 2·radius). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the lens. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius not positive or distance not in [0, 2r). |
Example
round(lens_area(5, 6), 4) 28.0544
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
midpoint_geo(lat1: float, lon1: float, lat2: float, lon2: float) -> tuple
¶
Computes the geographic midpoint between two coordinates on a sphere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat1
|
float
|
Latitude of point 1. |
required |
lon1
|
float
|
Longitude of point 1. |
required |
lat2
|
float
|
Latitude of point 2. |
required |
lon2
|
float
|
Longitude of point 2. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple (latitude, longitude) of the midpoint. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
mlat, mlon = midpoint_geo(40.4168, -3.7038, 48.8566, 2.3522) round(mlat, 2) 44.7
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
normalize_angle(angle: float, full_turn: float = 2.0 * math.pi) -> float
¶
Normalize an angle to the range [0, full_turn).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
Angle value. |
required |
full_turn
|
float
|
Full revolution size (default 2π for radians, use 360 for degrees). |
2.0 * pi
|
Returns:
| Type | Description |
|---|---|
float
|
Angle in [0, full_turn). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If full_turn ≤ 0. |
Usage Example
round(normalize_angle(7.0), 4) 0.7168
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
paraboloid_volume(radius: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the volume of a circular paraboloid.
V = (1/2)·π·r²·h
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Base radius. |
required |
height
|
Union[int, float]
|
Height of the paraboloid. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the paraboloid. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If inputs are not positive. |
Example
import math round(paraboloid_volume(3, 4), 4) 56.5487
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
parallelogram_area(base: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the area of a parallelogram: A = b · h.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
Union[int, float]
|
Base length. |
required |
height
|
Union[int, float]
|
Perpendicular height. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If dimensions are not positive. |
Example
parallelogram_area(8, 5) 40.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
point_in_circle(px: float, py: float, cx: float, cy: float, radius: float) -> bool
¶
Checks if a point (px, py) lies inside a circle centred at (cx, cy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
px
|
float
|
X-coordinate of the point. |
required |
py
|
float
|
Y-coordinate of the point. |
required |
cx
|
float
|
X-coordinate of circle centre. |
required |
cy
|
float
|
Y-coordinate of circle centre. |
required |
radius
|
float
|
Circle radius (positive). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the point is inside or on the circle boundary. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius is not positive. |
Example
point_in_circle(1, 1, 0, 0, 2) True point_in_circle(3, 0, 0, 0, 2) False
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
point_in_triangle(px: float, py: float, ax: float, ay: float, bx: float, by: float, cx: float, cy: float) -> bool
¶
Checks if a point (px, py) is inside the triangle (A, B, C).
Uses the barycentric coordinate method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
px
|
float
|
X-coordinate of the point. |
required |
py
|
float
|
Y-coordinate of the point. |
required |
ax
|
float
|
X-coordinate of vertex A. |
required |
ay
|
float
|
Y-coordinate of vertex A. |
required |
bx
|
float
|
X-coordinate of vertex B. |
required |
by
|
float
|
Y-coordinate of vertex B. |
required |
cx
|
float
|
X-coordinate of vertex C. |
required |
cy
|
float
|
Y-coordinate of vertex C. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the point is inside or on the triangle boundary. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
point_in_triangle(1, 1, 0, 0, 4, 0, 0, 4) True point_in_triangle(5, 5, 0, 0, 4, 0, 0, 4) False
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
polar_to_cartesian(r: float, theta: float) -> tuple[float, float]
¶
Convert polar coordinates (r, θ) to Cartesian (x, y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
Radial distance. |
required |
theta
|
float
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple (x, y). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
polar_to_cartesian(1.0, 0.0) (1.0, 0.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
power_of_point(distance: Union[int, float], radius: Union[int, float]) -> float
¶
Return the power of a point with respect to a circle.
Power = d² − r². Positive when the point is outside, zero on the circle, negative inside.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
Union[int, float]
|
Distance from the point to the centre (≥ 0). |
required |
radius
|
Union[int, float]
|
Radius of the circle (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Power of the point as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If distance < 0 or radius ≤ 0. |
Example
power_of_point(5, 3) 16.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
pyramid_volume(base_area: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the volume of a pyramid: V = (1/3)·B·h.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_area
|
Union[int, float]
|
Area of the base. |
required |
height
|
Union[int, float]
|
Perpendicular height. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If dimensions are not positive. |
Example
round(pyramid_volume(25, 6), 4) 50.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
radians_to_degrees(radians: float) -> float
¶
Converts an angle from radians to degrees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The equivalent angle in degrees. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
radians_to_degrees(math.pi) 180.0 radians_to_degrees(math.pi / 2) 90.0
Cost: O(1), simple angle conversion.
Source code in shortfx/fxNumeric/trigonometry_functions.py
regular_polygon_apothem(side_length: Union[int, float], n_sides: int) -> float
¶
Return the apothem of a regular polygon.
Apothem = a / (2 · tan(π / n)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
side_length
|
Union[int, float]
|
Length of one side (must be > 0). |
required |
n_sides
|
int
|
Number of sides (must be ≥ 3). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Apothem length as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If side_length is not numeric or n_sides not int. |
ValueError
|
If side_length ≤ 0 or n_sides < 3. |
Example
round(regular_polygon_apothem(1, 6), 6) 0.866025
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
regular_polygon_area(n_sides: int, side_length: Union[int, float]) -> float
¶
Calculate the area of a regular polygon: A = (n·s²) / (4·tan(π/n)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_sides
|
int
|
Number of sides (≥ 3). |
required |
side_length
|
Union[int, float]
|
Length of each side. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the regular polygon. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n_sides is not int or side_length not numeric. |
ValueError
|
If n_sides < 3 or side_length not positive. |
Example
round(regular_polygon_area(6, 2), 4) 10.3923
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
regular_polygon_exterior_angle(n_sides: int) -> float
¶
Calculate the exterior angle of a regular polygon.
angle = 360 / n (result in degrees).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_sides
|
int
|
Number of sides (must be ≥ 3). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Exterior angle in degrees. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n_sides is not an integer. |
ValueError
|
If n_sides < 3. |
Example
regular_polygon_exterior_angle(6) 60.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
regular_polygon_interior_angle(n_sides: int) -> float
¶
Calculate the interior angle of a regular polygon.
angle = (n - 2) · 180 / n (result in degrees).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_sides
|
int
|
Number of sides (must be ≥ 3). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Interior angle in degrees. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n_sides is not an integer. |
ValueError
|
If n_sides < 3. |
Example
regular_polygon_interior_angle(6) 120.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
regular_polygon_perimeter(n_sides: int, side_length: Union[int, float]) -> float
¶
Calculate the perimeter of a regular polygon: P = n · s.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_sides
|
int
|
Number of sides (≥ 3). |
required |
side_length
|
Union[int, float]
|
Length of each side. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Perimeter. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If n_sides is not int or side_length not numeric. |
ValueError
|
If n_sides < 3 or side_length not positive. |
Example
regular_polygon_perimeter(6, 5) 30.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
reuleaux_triangle_area(side: Union[int, float]) -> float
¶
Return the area of a Reuleaux triangle.
A = (π − √3) / 2 · s².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
side
|
Union[int, float]
|
Side length of the equilateral triangle (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the Reuleaux triangle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If side is not numeric. |
ValueError
|
If side ≤ 0. |
Example
round(reuleaux_triangle_area(1), 6) 0.704771
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
rhombus_area(diagonal1: Union[int, float], diagonal2: Union[int, float]) -> float
¶
Calculate the area of a rhombus: A = (d₁·d₂) / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagonal1
|
Union[int, float]
|
Length of the first diagonal. |
required |
diagonal2
|
Union[int, float]
|
Length of the second diagonal. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the rhombus. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If diagonals are not positive. |
Example
rhombus_area(10, 8) 40.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
rotation_2d(x: float, y: float, angle: float) -> tuple
¶
Rotates a 2D point (x, y) by an angle in radians around the origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X-coordinate. |
required |
y
|
float
|
Y-coordinate. |
required |
angle
|
float
|
Rotation angle in radians (counter-clockwise positive). |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple (x', y') of the rotated point. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
import math rx, ry = rotation_2d(1, 0, math.pi / 2) (round(rx, 10), round(ry, 10)) (0.0, 1.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
sagitta(radius: float, angle_radians: float) -> float
¶
Compute the sagitta (arrow height): r(1 - cos(θ/2)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius of the circle. |
required |
angle_radians
|
float
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sagitta value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius < 0. |
Usage Example
round(sagitta(1.0, 1.0), 4) 0.1224
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
salinon_area(r: Union[int, float], r1: Union[int, float]) -> float
¶
Return the area of a salinon.
The salinon consists of four semicircles. Its area equals the area of the circle with diameter equal to the line connecting the tops of the two inner semicircles:
A = π · ((r + r1) / 2)².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
Union[int, float]
|
Radius of the outer semicircle (must be > 0). |
required |
r1
|
Union[int, float]
|
Radius of the inner semicircle (must be > 0, r1 < r). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the salinon. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If r or r1 ≤ 0, or r1 ≥ r. |
Example
round(salinon_area(4, 2), 6) 28.274334
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
secant(angle_radians: float) -> float
¶
Calculates the secant of an angle. Sec(X) = 1 / Cos(X)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The secant of the given angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If cosine(angle_radians) is zero (secant is undefined). |
Example
round(secant(0), 10) # sec(0 degrees) 1.0 round(secant(math.pi), 10) # sec(180 degrees) -1.0
Cost: O(1), derived trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
sector_arc_length(radius: Union[int, float], angle: Union[int, float]) -> float
¶
Calculate the arc length of a circular sector: L = r · θ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius. |
required |
angle
|
Union[int, float]
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Arc length. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius not positive or angle negative. |
Example
import math round(sector_arc_length(5, math.pi / 3), 4) 5.236
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
sector_area(radius: float, angle_radians: float) -> float
¶
Compute sector area: r²θ/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius. |
required |
angle_radians
|
float
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sector area. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius < 0. |
Usage Example
round(sector_area(5.0, 1.0), 4) 12.5
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
segment_area(radius: float, angle_radians: float) -> float
¶
Compute circular segment area: r²(θ - sin(θ))/2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Radius. |
required |
angle_radians
|
float
|
Central angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Segment area. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
ValueError
|
If radius < 0. |
Usage Example
round(segment_area(5.0, 1.0), 4) 1.9816
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
sinc(x: float) -> float
¶
Calculates the normalized sinc function: sin(pix) / (pix).
Returns 1.0 when x == 0 (limit). Widely used in signal processing, Fourier analysis, and interpolation theory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Input value. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Normalized sinc of x. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If x is not numeric. |
Example
sinc(0) 1.0 round(sinc(0.5), 10) 0.6366197724
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
sine(angle_radians: float) -> float
¶
Calculates the sine of an angle.
The sine function (sin) is one of the primary trigonometric functions. It relates the ratio of the length of the opposite side to the length of the hypotenuse in a right-angled triangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sine of the given angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
Example
sine(math.pi / 2) # sin(90 degrees) 1.0 sine(0) 0.0
Cost: O(1), standard trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
sinusoidal_wave(amplitude: float, frequency: float, t: float, phase: float = 0.0) -> float
¶
Evaluate a sinusoidal wave: A·sin(2πft + φ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amplitude
|
float
|
Peak amplitude A. |
required |
frequency
|
float
|
Frequency f in Hz. |
required |
t
|
float
|
Time in seconds. |
required |
phase
|
float
|
Phase offset φ in radians (default 0). |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Wave value at time t. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
round(sinusoidal_wave(1.0, 1.0, 0.25), 4) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
solar_elevation(d: object, latitude: float, longitude: float) -> float
¶
Estimate the solar elevation angle for a given datetime and location.
Uses a simplified astronomical algorithm (adequate for ±1° accuracy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
object
|
A |
required |
latitude
|
float
|
Observer latitude in degrees. |
required |
longitude
|
float
|
Observer longitude in degrees. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Solar elevation angle in degrees (negative if below horizon). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If d is not a datetime or coordinates not numeric. |
ValueError
|
If latitude/longitude out of range. |
Example
from datetime import datetime round(solar_elevation(datetime(2026, 6, 21, 12, 0), 40.0, -3.7)) 73
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 | |
spherical_cap_area(sphere_radius: Union[int, float], cap_height: Union[int, float]) -> float
¶
Calculate the curved surface area of a spherical cap: A = 2·π·R·h.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sphere_radius
|
Union[int, float]
|
Radius of the sphere. |
required |
cap_height
|
Union[int, float]
|
Height of the cap. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Curved surface area of the cap. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If dimensions are not positive or cap_height > 2·sphere_radius. |
Example
round(spherical_cap_area(5, 2), 4) 62.8319
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_cap_volume(sphere_radius: Union[int, float], cap_height: Union[int, float]) -> float
¶
Calculate the volume of a spherical cap: V = (π·h²/3)·(3R - h).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sphere_radius
|
Union[int, float]
|
Radius of the sphere. |
required |
cap_height
|
Union[int, float]
|
Height of the cap (must be ≤ 2·R). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the spherical cap. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If dimensions are not positive or cap_height > 2·sphere_radius. |
Example
round(spherical_cap_volume(5, 2), 4) 54.4543
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_law_of_cosines(a: float, b: float, C: float) -> float
¶
Compute side c using the spherical law of cosines.
cos(c) = cos(a)cos(b) + sin(a)sin(b)cos(C)
All angles in radians. a, b are arc lengths (sides), C is the included angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Side a in radians. |
required |
b
|
float
|
Side b in radians. |
required |
C
|
float
|
Included angle C in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Side c in radians. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
Usage Example
round(spherical_law_of_cosines(1.0, 1.0, 1.0), 4) 0.8305
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_lune_area(radius: Union[int, float], angle: Union[int, float]) -> float
¶
Return the surface area of a spherical lune.
A = 2 · R² · θ, where θ is the dihedral angle in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the sphere (must be > 0). |
required |
angle
|
Union[int, float]
|
Dihedral angle in radians (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Surface area of the lune as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If radius or angle is not positive. |
Example
round(spherical_lune_area(5, math.pi / 3), 4) 52.3599
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_sector_volume(radius: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the volume of a spherical sector.
V = (2/3)·π·r²·h
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the sphere. |
required |
height
|
Union[int, float]
|
Height of the spherical cap. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the spherical sector. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If inputs are not positive or h > 2r. |
Example
import math round(spherical_sector_volume(5, 2), 4) 104.7198
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_to_cartesian(r: float, theta: float, phi: float) -> tuple[float, float, float]
¶
Convert spherical coordinates (r, θ, φ) to Cartesian (x, y, z).
θ is polar angle from z-axis, φ is azimuthal angle from x-axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
float
|
Radial distance. |
required |
theta
|
float
|
Polar angle in radians [0, π]. |
required |
phi
|
float
|
Azimuthal angle in radians [0, 2π]. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
Tuple (x, y, z). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If arguments are not numeric. |
Usage Example
tuple(round(v, 4) for v in spherical_to_cartesian(1.0, 0.0, 0.0)) (0.0, 0.0, 1.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_wedge_volume(radius: Union[int, float], angle: Union[int, float]) -> float
¶
Calculate the volume of a spherical wedge (lune).
V = (2/3)·r³·θ where θ is the dihedral angle in radians.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the sphere. |
required |
angle
|
Union[int, float]
|
Dihedral angle in radians, in (0, 2π]. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the spherical wedge. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radius not positive or angle not in (0, 2π]. |
Example
import math round(spherical_wedge_volume(5, math.pi / 2), 4) 130.8997
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spherical_zone_area(radius: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the surface area of a spherical zone A = 2·π·r·h.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the sphere. |
required |
height
|
Union[int, float]
|
Height of the zone. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Surface area of the spherical zone. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If inputs are not positive or h > 2r. |
Example
import math round(spherical_zone_area(5, 3), 4) 94.2478
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
spheroid_volume(equatorial_radius: Union[int, float], polar_radius: Union[int, float]) -> float
¶
Return the volume of a spheroid (ellipsoid of revolution).
V = (4/3) · π · a² · c, where a is the equatorial and c the polar semi-axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
equatorial_radius
|
Union[int, float]
|
Equatorial semi-axis (must be > 0). |
required |
polar_radius
|
Union[int, float]
|
Polar semi-axis (must be > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the spheroid as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If any argument ≤ 0. |
Example
round(spheroid_volume(6378, 6357), 0) 1083141285735.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
stadium_area(radius: Union[int, float], straight_length: Union[int, float]) -> float
¶
Return the area of a stadium (discorectangle).
A = π · r² + 2 · r · a, where a is the length of the straight section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the semicircular ends (must be > 0). |
required |
straight_length
|
Union[int, float]
|
Length of the straight section (must be ≥ 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the stadium as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If radius ≤ 0 or straight_length < 0. |
Example
round(stadium_area(5, 10), 4) 178.5398
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
stadium_perimeter(radius: Union[int, float], straight_length: Union[int, float]) -> float
¶
Return the perimeter of a stadium (discorectangle).
P = 2π · r + 2 · a.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
Union[int, float]
|
Radius of the semicircular ends (must be > 0). |
required |
straight_length
|
Union[int, float]
|
Length of the straight section (must be ≥ 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Perimeter of the stadium as a float. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If any argument is not numeric. |
ValueError
|
If radius ≤ 0 or straight_length < 0. |
Example
round(stadium_perimeter(5, 10), 4) 51.4159
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
tangent(angle_radians: float) -> float
¶
Calculates the tangent of an angle.
The tangent function (tan) is one of the primary trigonometric functions. It relates the ratio of the length of the opposite side to the length of the adjacent side in a right-angled triangle. It is also equivalent to sin(x) / cos(x).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
The angle in radians. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The tangent of the given angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a float or an integer. |
ValueError
|
If the tangent is undefined (angle is an odd multiple of pi/2). |
Example
tangent(0) 0.0 round(tangent(math.pi / 4), 10) # tan(45 degrees) 1.0
Cost: O(1), standard trigonometric function.
Source code in shortfx/fxNumeric/trigonometry_functions.py
torus_surface_area(major_radius: Union[int, float], minor_radius: Union[int, float]) -> float
¶
Calculate the surface area of a torus: A = 4π²·R·r.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
major_radius
|
Union[int, float]
|
Distance from center of torus to center of tube. |
required |
minor_radius
|
Union[int, float]
|
Radius of the tube. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Surface area. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radii are not positive or minor >= major. |
Example
round(torus_surface_area(5, 2), 4) 394.7842
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
torus_volume(major_radius: Union[int, float], minor_radius: Union[int, float]) -> float
¶
Calculate the volume of a torus: V = 2π²·R·r².
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
major_radius
|
Union[int, float]
|
Distance from center of torus to center of tube. |
required |
minor_radius
|
Union[int, float]
|
Radius of the tube. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the torus. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If radii are not positive or minor >= major. |
Example
round(torus_volume(5, 2), 4) 394.7842
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
trapezoid_area(base1: Union[int, float], base2: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the area of a trapezoid: A = (b₁ + b₂) · h / 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base1
|
Union[int, float]
|
Length of the first base. |
required |
base2
|
Union[int, float]
|
Length of the second base. |
required |
height
|
Union[int, float]
|
Perpendicular height. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Area of the trapezoid. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If any dimension is not positive. |
Example
trapezoid_area(5, 7, 4) 24.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
triangle_area_sas(a: Union[int, float], b: Union[int, float], angle_c: float) -> float
¶
Computes the area of a triangle given two sides and the included angle.
Area = 0.5 * a * b * sin(C).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Union[int, float]
|
Length of the first side (positive). |
required |
b
|
Union[int, float]
|
Length of the second side (positive). |
required |
angle_c
|
float
|
Included angle in radians (0, π). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The area of the triangle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If sides are non-positive or angle is out of (0, π). |
Example
import math round(triangle_area_sas(5, 7, math.pi / 6), 4) 8.75
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
triangle_centroid(ax: float, ay: float, bx: float, by: float, cx: float, cy: float) -> tuple
¶
Computes the centroid (centre of mass) of a triangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
float
|
X-coordinate of vertex A. |
required |
ay
|
float
|
Y-coordinate of vertex A. |
required |
bx
|
float
|
X-coordinate of vertex B. |
required |
by
|
float
|
Y-coordinate of vertex B. |
required |
cx
|
float
|
X-coordinate of vertex C. |
required |
cy
|
float
|
Y-coordinate of vertex C. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple (x, y) of the centroid. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
triangle_centroid(0, 0, 3, 0, 0, 3) (1.0, 1.0)
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
triangle_circumradius(a: float, b: float, c: float) -> float
¶
Computes the circumradius of a triangle given its three side lengths.
R = (a · b · c) / (4 · Area)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Length of side a. |
required |
b
|
float
|
Length of side b. |
required |
c
|
float
|
Length of side c. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Circumradius of the triangle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If sides do not form a valid triangle. |
Example
round(triangle_circumradius(3, 4, 5), 6) 2.5
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
triangle_incircle_radius(a: float, b: float, c: float) -> float
¶
Computes the inradius of a triangle given its three side lengths.
r = Area / s, where s = (a+b+c)/2 and Area via Heron's formula.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Length of side a. |
required |
b
|
float
|
Length of side b. |
required |
c
|
float
|
Length of side c. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Inradius of the triangle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If sides do not form a valid triangle. |
Example
round(triangle_incircle_radius(3, 4, 5), 6) 1.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
versine(angle_radians: float) -> float
¶
Computes the versine: versin(x) = 1 - cos(x).
A classical trigonometric function used in navigation and surveying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle_radians
|
float
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Versine of the angle. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not numeric. |
Example
versine(0) 0.0 round(versine(math.pi), 10) 2.0
Complexity: O(1)
Source code in shortfx/fxNumeric/trigonometry_functions.py
vincenty_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float
¶
Geodesic distance between two points using Vincenty's formulae.
Uses the WGS-84 ellipsoid (a = 6378137 m, f = 1/298.257223563).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat1
|
float
|
Latitude of point 1 in degrees. |
required |
lon1
|
float
|
Longitude of point 1 in degrees. |
required |
lat2
|
float
|
Latitude of point 2 in degrees. |
required |
lon2
|
float
|
Longitude of point 2 in degrees. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Distance in metres. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
Example
round(vincenty_distance(40.4168, -3.7038, 48.8566, 2.3522)) 1052744
Complexity: O(1) — iterative but bounded.
Source code in shortfx/fxNumeric/trigonometry_functions.py
4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 | |
wedge_volume(base_area: Union[int, float], height: Union[int, float]) -> float
¶
Calculate the volume of a wedge (triangular prism with half-base).
V = (1/2) · A_base · h
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_area
|
Union[int, float]
|
Area of the rectangular face. |
required |
height
|
Union[int, float]
|
Height (depth) of the wedge. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Volume of the wedge. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numeric. |
ValueError
|
If inputs are not positive. |
Example
wedge_volume(20, 5) 50.0
Complexity: O(1)