abstract-math 0.0.0.16__py3-none-any.whl → 0.0.0.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of abstract-math might be problematic. Click here for more details.

@@ -0,0 +1,104 @@
1
+ from ..imports import *
2
+ from ..constants import *
3
+ # --- Spherical cap (true horizon-limited visibility) ---
4
+ def get_central_angle(r_m: float, h_m: float) -> float:
5
+ """Angle at Earth's center from observer to horizon (radians)."""
6
+ rh = add(r_m, h_m)
7
+ # clamp to avoid domain issues
8
+ val = max(-1.0, min(1.0, div(r_m, rh)))
9
+ return math.acos(val)
10
+
11
+ def get_h_cap(r_m: float, h_m: float, theta: Optional[float] = None) -> float:
12
+ """Spherical cap height (meters)."""
13
+ if theta is None:
14
+ theta = get_central_angle(r_m, h_m)
15
+ return mul(r_m, sub(1.0, math.cos(theta)))
16
+
17
+ def spherical_cap_area(observer_altitude: float, units: str = 'meters'):
18
+ """
19
+ Visible spherical cap area from altitude (same units as input returned in unit^2).
20
+ """
21
+ r_m = earth_radius('meters')
22
+ h_m = convert(observer_altitude, units, 'meters')
23
+
24
+ theta = get_central_angle(r_m, h_m)
25
+ h_cap_m = get_h_cap(r_m, h_m, theta)
26
+ area_m2 = mul(2 * pi() * r_m, h_cap_m) # 2π R h
27
+ # return in requested units^2
28
+ area_u2 = mul(area_m2, exp(_factor('meters', units), 2))
29
+ return area_u2, convert(h_cap_m, 'meters', units), theta
30
+
31
+ def percent_visible(observer_altitude: float, units: str = 'meters') -> float:
32
+ cap_area_u2, _, _ = spherical_cap_area(observer_altitude, units)
33
+ full_area_u2 = full_earth_surface_area(units)
34
+ return mul(div(cap_area_u2, full_area_u2), 100.0)
35
+
36
+ # --- Camera/FOV flat-projection helper (approximate) ---
37
+ def visible_area_flat(fov_degrees: float, altitude_m: float, units: str = 'meters'):
38
+ """
39
+ Given altitude in meters, return (area_m2, visible_radius_m). `units` arg is ignored,
40
+ kept for backward compatibility.
41
+ """
42
+ fov_radians = math.radians(fov_degrees)
43
+ visible_radius_m = altitude_m * math.tan(fov_radians / 2.0)
44
+ area_m2 = math.pi * (visible_radius_m ** 2)
45
+ return area_m2, visible_radius_m
46
+
47
+ def visible_surface_angle(visible_radius: float, sphere_radius: float) -> tuple[float, float]:
48
+ """Chord-based angular span (approximate)."""
49
+ chord_length = mul(2.0, visible_radius)
50
+ angle_rad = mul(2.0, math.asin(div(chord_length, mul(2.0, sphere_radius))))
51
+ angle_deg = math.degrees(angle_rad)
52
+ return angle_rad, angle_deg
53
+
54
+ # --- FOV triangle pack (kept but made unit-consistent) ---
55
+ def get_triangle_area(a: float, b: float, c: float):
56
+ s = (a + b + c) / 2.0
57
+ area = math.sqrt(max(0.0, s * (s - a) * (s - b) * (s - c)))
58
+ return area, s
59
+
60
+ def get_medians(a: float, b: float, c: float) -> float:
61
+ # median from side 'a'
62
+ return 0.5 * math.sqrt(max(0.0, 2*b*b + 2*c*c - a*a))
63
+
64
+ def get_triangle_medians(a: float, b: float, c: float):
65
+ return {"ma": get_medians(b, c, a), "mb": get_medians(a, c, b), "mc": get_medians(a, b, c)}
66
+
67
+ def get_triangle_heights(a: float, b: float, c: float, area: float):
68
+ ha = mul(2.0, div(area, a))
69
+ hb = mul(2.0, div(area, b))
70
+ hc = mul(2.0, div(area, c))
71
+ return {"ha": ha, "hb": hb, "hc": hc}
72
+
73
+ def compute_fov_triangle(altitude: float, fov_angle_deg: float, units: str = 'meters'):
74
+ """Simple isosceles triangle model for a camera at altitude."""
75
+ a = convert(altitude, units, 'meters')
76
+ fov_angle_rad = math.radians(fov_angle_deg)
77
+ base = 2.0 * a * math.tan(fov_angle_rad / 2.0)
78
+ b = c = a
79
+
80
+ # Triangle inequality guard
81
+ if not ((base + b > c) and (base + c > b) and (b + c > base)):
82
+ return {"error": "Invalid triangle geometry. Lower FOV or increase altitude.",
83
+ "sides": {"a": base, "b": b, "c": c}}
84
+
85
+ triangle_area, s = get_triangle_area(base, b, c)
86
+ medians = get_triangle_medians(base, b, c)
87
+ heights = get_triangle_heights(base, b, c, triangle_area)
88
+ vertices = {"A": (0, 0), "B": (base / 2.0, a), "C": (-base / 2.0, a)}
89
+ inradius = div(triangle_area, s)
90
+ circumradius = 0.5 * a # right-ish simplification for this layout
91
+
92
+ return {
93
+ "sides": {"a": base, "b": b, "c": c},
94
+ "area": triangle_area,
95
+ "perimeter": base + 2.0 * a,
96
+ "semiperimeter": s,
97
+ "heights": heights,
98
+ "medians": medians,
99
+ "vertices": vertices,
100
+ "inradius": inradius,
101
+ "circumradius": circumradius
102
+ }
103
+
104
+
@@ -0,0 +1,26 @@
1
+ #src/utils/velocity_utils.py
2
+ from ..imports import *
3
+ from ..constants import *
4
+
5
+ def distance_per_time_to_mps(v: float, dist_units: str, time_units: str) -> float:
6
+ """
7
+ Convert <v> in (<dist_units>/<time_units>) to m/s.
8
+ """
9
+ # distance: unit -> meters
10
+ norm_dist_unit = normalize_distance_unit(dist_units) # <-- was normalize_time_unit
11
+ meters_per_unit = get_distance_unit_conversions(norm_dist_unit)["conv"]["meters"]
12
+ v_meters_per_timeunit = mul(v, meters_per_unit)
13
+
14
+ # time: timeunit -> seconds
15
+ sec_per_time = seconds_per(time_units) # from time_constants.py
16
+ return div(v_meters_per_timeunit, sec_per_time)
17
+
18
+ def mps_to_distance_per_time(v_mps: float, dist_units: str, time_units: str) -> float:
19
+ """
20
+ Convert m/s to <dist_units>/<time_units>.
21
+ """
22
+ norm_dist_unit = normalize_distance_unit(dist_units)
23
+ meters_per_unit = get_distance_unit_conversions(norm_dist_unit)["conv"]["meters"]
24
+ v_units_per_sec = div(v_mps, meters_per_unit) # [dist_units / s]
25
+ sec_per_time = seconds_per(time_units)
26
+ return mul(v_units_per_sec, sec_per_time) # [dist_units / time_units]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstract_math
3
- Version: 0.0.0.16
3
+ Version: 0.0.0.18
4
4
  Author: putkoff
5
5
  Author-email: partners@abstractendeavors.com
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -0,0 +1,23 @@
1
+ abstract_math/__init__.py,sha256=wr-kwaB8micSsR1nCHuDXRlsL59DWlqZQFN7M_rfZys,80
2
+ abstract_math/derive_tokens.py,sha256=0rHanu6-UweOXxVuPn-DQsbUn7Xaoz39TQJiWDe7K5Q,4382
3
+ abstract_math/safe_math.py,sha256=Rt5STOAuRRKhV1-YNfhX-OlhwVgRpk6XdN74UjnHvRc,5394
4
+ abstract_math/flask_scripts/__init__.py,sha256=En366EX8hQ7FRsh_8hgjrgHFAQkkVi72wFcpSiOxz-s,26
5
+ abstract_math/flask_scripts/flask_utils.py,sha256=z6gpPshiOeqNANBQkZMZPkegCzj-GK3OpSOi1lN19Sc,28483
6
+ abstract_math/flask_scripts/make_flask.py,sha256=6c7Vt_iSTDf_bhmBkK5E-GIiHGbhkwHl_B_79C3BTZY,104
7
+ abstract_math/solar_math/__init__.py,sha256=FfPkmWi3cQ3BLvUUUf6k22rGBE8scDL1EoM5l24biVo,39
8
+ abstract_math/solar_math/flask_utils.py,sha256=c82LrZ0dKC3Y8LxqOs1zDR6gRy8oXSx9balBD18gNB0,459
9
+ abstract_math/solar_math/main.py,sha256=EtcUmUWj27c7mcnm-hlfeCeYFuPytPevXx5vClVu6Q8,10000
10
+ abstract_math/solar_math/src/__init__.py,sha256=qeal73F-NLu6sO_YSmD_komVpe17f0OFy2IfBR2QU_s,70
11
+ abstract_math/solar_math/src/imports.py,sha256=U2wY9NwbzarE6IXrIRpPbRV2e42V3cX8HS8f_80CZ7I,182
12
+ abstract_math/solar_math/src/constants/__init__.py,sha256=HpRa4MWkJZu3Wcx6KchB8__RL4FfkVqRw78TAnjRRwo,691
13
+ abstract_math/solar_math/src/constants/distance_constants.py,sha256=stM3nWxpANQEtoxFcbxpO0ly_UM4JJ2aH0VK42fHw6s,1985
14
+ abstract_math/solar_math/src/constants/planet_constants.py,sha256=tt2nbFtRtYhUU9D918WK91D-S5Cv0HEJ-1j7f9Yb50w,6602
15
+ abstract_math/solar_math/src/constants/time_constants.py,sha256=uVDMldwjJqKwXzHcAb-Z8QM20JrxSwLXlogjD_SXwRo,1874
16
+ abstract_math/solar_math/src/utils/__init__.py,sha256=Vb2bfx1p9YSmhnbqXBjGVPt1OQZ9I7PG_fMQdFqj-3k,91
17
+ abstract_math/solar_math/src/utils/escape_velocity.py,sha256=K_t6q5kO0jJjkhWfIpTJlfJCLBneYh0LKf3FwQf0ye4,2972
18
+ abstract_math/solar_math/src/utils/geometry_utils.py,sha256=Ij4mASNFp2-CWy425fxMTEuMPuAZHs-E0qvi3BjaNkk,4169
19
+ abstract_math/solar_math/src/utils/velocity_utils.py,sha256=_SyOscVvYsvbm1T1Rh4uqegXdf61mHll5s3UfQcdUnU,1162
20
+ abstract_math-0.0.0.18.dist-info/METADATA,sha256=tb1dh0iK-jG-yHIQerV-P6E2Kwoqt7VsXvT-C59YhN0,1150
21
+ abstract_math-0.0.0.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ abstract_math-0.0.0.18.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
23
+ abstract_math-0.0.0.18.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
abstract_math/deriveit.py DELETED
@@ -1,97 +0,0 @@
1
- from decimal import Decimal, getcontext
2
- from .safe_math import *
3
- getcontext().prec = 50 # High precision for accuracy
4
- SOL_DECIMAL_PLACE = 9
5
- SOL_LAMPORTS = sol_lamports =int(exponential(1,exp=SOL_DECIMAL_PLACE,num=1))
6
- def get_proper_args(strings,*args,**kwargs):
7
- properArgs = []
8
- for key in strings:
9
- kwarg = kwargs.get(key)
10
- if kwarg == None and args:
11
- kwarg = args[0]
12
- args = [] if len(args) == 1 else args[1:]
13
- properArgs.append(kwarg)
14
- return properArgs
15
-
16
- #lamports
17
- def get_lamports(integer):
18
- return exp_it(10,len(str(integer))+1,1)
19
- def get_lamport_difference(lamports,virtual_lamports):
20
- integer = int(virtual_lamports/lamports)
21
- exponential = len(str(integer))
22
- return int(exponential(1,exp=exponential,num=1))
23
- #virtual reserves
24
- def get_vitual_reserves(*args,**kwargs):
25
- proper_args = get_proper_args(["virtualSolReserves","virtualTokenReserves"],*args,**kwargs)
26
- return proper_args
27
- def get_virtual_reserve_ratio(*ars,**kwargs):
28
- proper_args = get_vitual_reserves(*args,**kwargs)
29
- return divide_it(*proper_args)
30
- #sol reserves
31
- def get_virtual_sol_reservs(*args,**kwargs):
32
- proper_args = get_proper_args(["virtualSolReserves"],*args,**kwargs)
33
- return proper_args[0] if proper_args else proper_args
34
- def get_virtual_sol_lamports(*args,**kwargs):
35
- virtual_sol_reserves = get_virtual_sol_reservs(*args,**kwargs)
36
- virtual_sol_lamports = get_lamports(virtual_sol_reserves)
37
- return virtual_sol_lamports
38
- def get_virtual_sol_lamp_difference(*args,**kwargs):
39
- virtual_sol_lamports = get_virtual_sol_lamports(*args,**kwargs)
40
- return get_lamport_difference(SOL_LAMPORTS,virtual_sol_lamports)
41
- #sol Amount
42
- def get_sol_amount(*args,**kwargs):
43
- proper_args = get_proper_args(["solAmount"],*args,**kwargs)
44
- return proper_args[0] if proper_args else proper_args
45
- def getSolAmountUi(*args,**kwargs):
46
- sol_amount = get_sol_amount(*args,**kwargs)
47
- return exponential(sol_amount,SOL_DECIMAL_PLACE)
48
- #token reserves
49
- def get_virtual_token_reservs(*args,**kwargs):
50
- proper_args = get_proper_args(["virtualTokenReserves"],*args,**kwargs)
51
- return proper_args[0] if proper_args else proper_args
52
- def get_virtual_token_lamports(*args,**kwargs):
53
- virtual_token_reserves = get_virtual_token_reservs(*args,**kwargs)
54
- virtual_token_lamports = get_lamports(virtual_token_reserves)
55
- return virtual_token_lamports
56
- #token amount
57
- def get_token_amount(*args,**kwargs):
58
- proper_args = get_proper_args(["tokenAmount"],*args,**kwargs)
59
- return proper_args[0] if proper_args else proper_args
60
- def get_token_amount_ui(*args,**kwargs):
61
- token_amount = get_token_amount(*args,**kwargs)
62
- token_decimals = derive_token_decimals(*args,**kwargs)
63
- return exponential(token_amount,exp=token_decimals)
64
- #token derivision
65
- def derive_token_decimals_from_token_variables(variables):
66
- variables["price"] = get_price(**variables)
67
- variables["tokenDecimals"] = derive_decimals_from_vars(*args,**kwargs)
68
- return variables
69
- def get_derived_token_ratio(*args,**kwarg):
70
- derived_token_amount = derive_token_amount(*args,**kwargs)
71
- token_amount = get_token_amount(*args,**kwargs)
72
- ratio = divide_it(derived_token_amount,token_amount)
73
- return ratio
74
- def derive_token_amount(*args,**kwargs):
75
- virtual_token_reserves = get_virtual_token_reserves(*args,**kwargs)
76
- price = get_price(*args,**kwargs)
77
- derived_token_amount = divide_it(virtual_token_reserves,price)
78
- return derived_token_amount
79
- #derive variables
80
- def get_price(*args,**kwargs):
81
- reserve_ratios = get_virtual_reserve_ratio(*ars,**kwargs)
82
- virtual_sol_lamp_difference = get_virtual_sol_lamp_difference(*args,**kwargs)
83
- return reserve_ratios/virtual_sol_lamp_difference
84
- def derive_decimals_from_vars(*args,**kwargs):
85
- ratio = get_derived_token_ratio(*args,**kwarg)
86
- decimals = -1
87
- while abs(ratio - round(ratio)) > 1e-9:
88
- ratio *= 10
89
- decimals += 1
90
- return decimals
91
- def update_token_variables(variables):
92
- variables['solAmountUi'] = getSolAmountUi(**variables)
93
- variables['solDecimals'] = 9
94
- variables = derive_token_decimals_from_token_variables(variables)
95
- variables['tokenAmountUi'] = exponential(variables['tokenAmount'],variables["tokenDecimals"])
96
- return variables
97
-
@@ -1,8 +0,0 @@
1
- abstract_math/__init__.py,sha256=3I0YJakDUyWD7qXpdRsaEsmcA7IxwcWhoyecvDfOE98,54
2
- abstract_math/derive_tokens.py,sha256=Ba2hq3-W3NPmfko-Lf-58HfkBtl4kfN-GFuSZJMyiWM,4233
3
- abstract_math/deriveit.py,sha256=Og8QtDGRrgGbmaHTh-jEusg35jUpb74DgzslsxZ_2iU,4271
4
- abstract_math/safe_math.py,sha256=WIIiHELl3AqV2IdWlWd5Ca4TOD6qffeGNA33gJQqS6k,5378
5
- abstract_math-0.0.0.16.dist-info/METADATA,sha256=C9JFxjf0rGKI9LaXkNbC1JvgGkie_TUsUkQO8fGaarc,1150
6
- abstract_math-0.0.0.16.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
7
- abstract_math-0.0.0.16.dist-info/top_level.txt,sha256=b7jOgD9c0U-CGH-l7yxhMPukzD40kMEQkQRV_sGyVfE,14
8
- abstract_math-0.0.0.16.dist-info/RECORD,,