KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_calculator/transline/units.h
Go to the documentation of this file.
1/*
2 * units.h - some conversion definitions
3 *
4 * Copyright (C) 1992-2011 jean-pierre.charras
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this package. If not, see <https://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef __UNITS_H
23#define __UNITS_H
24
25#include <config.h>
26#include <cmath>
27
28#include "units_scales.h"
29
30#ifndef HAVE_CMATH_ASINH
31inline double asinh( double x )
32{
33 return log( x+sqrt(x*x+1) );
34}
35#endif
36
37#ifndef HAVE_CMATH_ACOSH
38inline double acosh( double x )
39{
40 // must be x>=1, if not return Nan (Not a Number)
41 if( x < 1.0 ) return sqrt( -1.0 );
42
43 // return only the positive result (as sqrt does).
44 return log( x+sqrt( x*x-1.0 ) );
45}
46#endif
47
48#ifndef HAVE_CMATH_ATANH
49inline double atanh( double x )
50{
51 // must be x>-1, x<1, if not return Nan (Not a Number)
52 if( !(x>-1.0 && x<1.0) ) return sqrt( -1.0 );
53
54 return log( (1.0+x)/(1.0-x) ) / 2.0;
55}
56#endif
57
58#define MU0 12.566370614e-7 // magnetic constant
59#define C0 299792458.0 // speed of light in vacuum
60
61// wave resistance in vacuum
62//
63// - From 1948 to 2019, Z₀ was defined to be exactly π*119.9169832 Ω (≈376.730_313_462 Ω).
64//
65// - The 2019 revision to SI changed it from a defined value to a measured value. In accordance
66// with this, the "2018" revision (based on 2018 measurements, values published 2019, rationale
67// published 2021) of the "CODATA Recommended Values of the Fundamental Physical Constants"
68// (<https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=931443>) gave the accepted measured
69// value as 376.730_313_668(57) Ω (the number in parenthesis is the margin of error).
70//
71// - The "2022" revision (based on 2022 measurements, values published 2024, rationale published
72// 2025) of CODATA (<https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=958143>) gave the
73// accepted measured value as 376.730_313_412(59) Ω.
74//
75// The most recent CODATA value can always be found at
76// <https://physics.nist.gov/cgi-bin/cuu/Value?z0>.
77//
78// - From its first use in 2011 (pre-v4), KiCad used the value 376.730_313_469_585_043_649_63, which
79// mysteriously doesn't quite match any of the above.
80//
81// - In 2021 (v6), KiCad updated to the 2018 CODATA value.
82//
83// - In 2026, KiCad updated to the 2022 CODATA value.
84#define ZF0 376.730313412
85
86// const to convert a attenuation / loss from log (Neper) to decibel
87// (1 Np = 8.68589 dB)
88const double LOG2DB = 20.0 / log( 10.0 );
89
90#endif /* __UNITS_H */
const double LOG2DB
double asinh(double x)
double atanh(double x)
double acosh(double x)