Metadata-Version: 2.1
Name: phys-const
Version: 0.1.2
Summary: Pack of physical constants.
Home-page: https://github.com/Rezenter/phys-const
Author: Rezenter
Author-email: nisovru@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

#  This module provides physical constants in uniform format.

## [C], electron charge.
q_e = 1.60217662e-19

## [J * s], Planks constant.
h = 6.62e-34

## [m / s], speed of light.
c = 299792458

## [kg], electron mass.
m_e = 9.10938356e-31

## [m], electron radius
r_o = 2.8179403267e-15

## [K], room temperature
t_room = 273 + 23

## [J / K], Boltzmann constant
k_b = 1.38064852e-23

## [F / m] = [A2 * s4 / (kg * m3)], permittivity of free space
eps_0: float = 8.85418781e-12

## Converts pressure from [Torr] to [Pa]
def torr_to_pa(torr):
    return torr * 7.5006 * 1e-3

## Converts temperature from [deg C] to [deg K]
def cels_to_kelv(cels: float) -> float:
    return cels + 273.15

## floating point infinity
inf = float('inf')

## linear interpolation
```
def interpolate(x_prev: float, x_tgt: float, x_next: float, y_prev: float, y_next: float) -> float:
    return y_prev + (y_next - y_prev) * (x_tgt - x_prev) / (x_next - x_prev)
```

## linear interpolation in array. x_arr must be descending.
```
def interpolate_arr(x_arr_desc: list[float], y_arr: list[float], x: float) -> float:
    if len(x_arr_desc) != len(y_arr):
        print('Input array have different length: %d vs %d. Throwing error' % (len(x_arr_desc), len(y_arr)))
        fuckOff
    if x >= x_arr_desc[0] or x <= x_arr_desc[-1]:
        print('Warning! x out of bounds!')
        return inf
    for ind in range(len(x_arr_desc) - 1):
        if x_arr_desc[ind] >= x > x_arr_desc[ind + 1]:
            return interpolate(x_prev=x_arr_desc[ind], x_tgt=x, x_next=x_arr_desc[ind + 1], y_prev=y_arr[ind], y_next=y_arr[ind + 1])
    print(x_arr_desc[0], x, x_arr_desc[-1])
    print('WTF?')
    return fuckOff
```

## radians to degrees converter
```
def rad_to_deg(deg: float) -> float:
    return deg * 180 / math.pi
```

## degrees to radians converter
```
def deg_to_rad(deg: float) -> float:
    return deg * math.pi / 180
```

## angle between two vectors. Result from 0 to 2Pi.
```
def vector_angle(first_x: float, first_y: float, second_x: float, second_y: float) -> float:
    angle = math.atan2(second_y - first_y, second_x - first_x)
    if angle < 0:
        angle += math.tau
    return angle
```

