KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 (C) 1992-2011 Kicad Developers, see change_log.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; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef __UNITS_H
25#define __UNITS_H
26
27#include <config.h>
28#include <cmath>
29
30#include "units_scales.h"
31
32#ifndef HAVE_CMATH_ASINH
33inline double asinh( double x )
34{
35 return log( x+sqrt(x*x+1) );
36}
37#endif
38
39#ifndef HAVE_CMATH_ACOSH
40inline double acosh( double x )
41{
42 // must be x>=1, if not return Nan (Not a Number)
43 if( x < 1.0 ) return sqrt( -1.0 );
44
45 // return only the positive result (as sqrt does).
46 return log( x+sqrt( x*x-1.0 ) );
47}
48#endif
49
50#ifndef HAVE_CMATH_ATANH
51inline double atanh( double x )
52{
53 // must be x>-1, x<1, if not return Nan (Not a Number)
54 if( !(x>-1.0 && x<1.0) ) return sqrt( -1.0 );
55
56 return log( (1.0+x)/(1.0-x) ) / 2.0;
57}
58#endif
59
60#define MU0 12.566370614e-7 // magnetic constant
61#define C0 299792458.0 // speed of light in vacuum
62#define ZF0 376.730313668 // wave resistance in vacuum
63
64// ZF0 value update:
65// https://physics.nist.gov/cgi-bin/cuu/Value?z0
66
67#endif /* __UNITS_H */
double asinh(double x)
Definition: units.h:33
double atanh(double x)
Definition: units.h:51
double acosh(double x)
Definition: units.h:40