WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
unitutils.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16
17#ifndef UTILS_UNIT_UTILS_H
18#define UTILS_UNIT_UTILS_H
19
20#include <math.h>
21
22#include "types.h"
23
24 // GNU-defined math constants
25 #if defined __USE_MISC || defined __USE_XOPEN || defined __APPLE__
26 #else
27 const floating_point M_E = 2.71828182845904523540; /* e */
28 const floating_point M_LOG2E = 1.44269504088896340740; /* log_2 e */
29 const floating_point M_LOG10E = 0.43429448190325182765; /* log_10 e */
30 const floating_point M_LN2 = 0.69314718055994530942; /* log_e 2 */
31 const floating_point M_LN10 = 2.30258509299404568402; /* log_e 10 */
32 const floating_point M_PI = 3.14159265358979323846; /* pi */
33 const floating_point M_PI_2 = 1.57079632679489661923; /* pi/2 */
34 const floating_point M_PI_4 = 0.78539816339744830962; /* pi/4 */
35 const floating_point M_1_PI = 0.31830988618379067154; /* 1/pi */
36 const floating_point M_2_PI = 0.63661977236758134308; /* 2/pi */
37 const floating_point M_2_SQRTPI = 1.12837916709551257390; /* 2/sqrt(pi) */
38 const floating_point M_SQRT2 = 1.41421356237309504880; /* sqrt(2) */
39 const floating_point M_SQRT1_2 = 0.70710678118654752440; /* 1/sqrt(2) */
40 #endif
41
42namespace warpos {
43
44 const floating_point TWO_PI = 2.0*M_PI;
45
46 // Angle conversion constants
47 const floating_point DEGREES_TO_RADIANS = M_PI/180.0;
48 const floating_point RADIANS_TO_DEGREES = 180.0/M_PI;
49
50 // PHYSICAL CONSTANTS
51 const floating_point SPEED_OF_LIGHT = 299792458.0; // [m/s]
52 const floating_point BOLTZMANN_CONSTANT = 1.380649e-23; // [W/K/Hz]
53
54 // DISTANCE CONVERSIONS
55 const floating_point AU_TO_METERS = 149597870700.0;
56 const floating_point METERS_TO_AU = 1.0/149597870700.0;
57
58 const floating_point KM_TO_METERS = 1000.0;
59 const floating_point METERS_TO_KM = 0.001;
60
61 const floating_point METERS_TO_FEET = 3.28084;
62 const floating_point FEET_TO_METERS = 1.0/METERS_TO_FEET;
63
64 const floating_point METERS_TO_INCHES = METERS_TO_FEET*12.0;
65 const floating_point INCHES_TO_METERS = 1.0/METERS_TO_INCHES;
66
67 const double METERS_TO_NAUTICAL_MILES = 1.0/1852.0; // per NIST Special Publication 811: Guide to the SI, Appendix B.9
68
69 // MASS CONVERSIONS
70 const double LBS_TO_KG = 0.45359237; // per NIST Special Publication 811: Guide to the SI, Appendix B.9
71 const double KG_TO_LBS = 1.0 / LBS_TO_KG;
72
73 // COMBINED UNIT CONVERSIONS
74 // Note: 1 Newton = 1 kg*m*s^2 -> 1 kg*m^2 = 1 N*m*s^2
75 const double POUND_FORCE_INCH_SECOND2_TO_METER2_KG = 0.1129848; // per NIST Special Publication 811: Guide to the SI, Appendix B.9, lbf*in -> N*m
76
77 // Time conversions
78 const floating_point SECONDS_TO_MILLISECONDS = 1000.0;
79 const floating_point SECONDS_TO_NANOSECONDS = 1000000000.0;
80 const floating_point NANOSECONDS_TO_SECONDS = 1.0 / SECONDS_TO_NANOSECONDS;
81 const floating_point MILLISECONDS_TO_NANOSECONDS = 1000000.0;
83 const floating_point SECONDS_TO_MICROSECONDS = 1000000.0;
85 const floating_point MICROSECONDS_TO_NANOSECONDS = 1000.0;
86 const floating_point MICROSECONDS_TO_MILLISECONDS = 1.0/1000.0;
87 const floating_point MINUTES_TO_SECONDS = 60.0;
88 const floating_point SECONDS_TO_MINUTES = 1.0 / MINUTES_TO_SECONDS;
90 const floating_point DAYS_TO_SECONDS = 24.0*HOURS_TO_SECONDS;
91 const floating_point YEARS_TO_SECONDS = 365.25*DAYS_TO_SECONDS; // TODO: Make this an acutual sidereal year or whatever its called (should be 365.249 or something like that, 2100 is NOT a leap year)
92
93 // PRESSURE CONVERSIONS
94 const floating_point PSI_TO_PASCAL = 6894.7572932;
95 const floating_point PASCAL_TO_PSI = 1.0/PSI_TO_PASCAL;
96 const floating_point MILLIBAR_TO_PASCAL = 100.0;
97 const floating_point PASCAL_TO_MILLIBAR = 1.0/MILLIBAR_TO_PASCAL;
98}
99
100#endif
Definition DeadReckon.cpp:20
const double POUND_FORCE_INCH_SECOND2_TO_METER2_KG
Definition unitutils.h:75
const floating_point PASCAL_TO_MILLIBAR
Definition unitutils.h:97
const floating_point RADIANS_TO_DEGREES
Definition unitutils.h:48
const floating_point KM_TO_METERS
Definition unitutils.h:58
const floating_point PSI_TO_PASCAL
Definition unitutils.h:94
const floating_point METERS_TO_INCHES
Definition unitutils.h:64
const floating_point SECONDS_TO_NANOSECONDS
Definition unitutils.h:79
const floating_point NANOSECONDS_TO_MILLISECONDS
Definition unitutils.h:82
const floating_point PASCAL_TO_PSI
Definition unitutils.h:95
const floating_point MICROSECONDS_TO_SECONDS
Definition unitutils.h:84
const floating_point NANOSECONDS_TO_SECONDS
Definition unitutils.h:80
const floating_point HOURS_TO_SECONDS
Definition unitutils.h:89
const floating_point TWO_PI
Definition unitutils.h:44
const floating_point YEARS_TO_SECONDS
Definition unitutils.h:91
const floating_point DEGREES_TO_RADIANS
Definition unitutils.h:47
const floating_point AU_TO_METERS
Definition unitutils.h:55
const floating_point FEET_TO_METERS
Definition unitutils.h:62
const floating_point SECONDS_TO_MILLISECONDS
Definition unitutils.h:78
const floating_point SECONDS_TO_MINUTES
Definition unitutils.h:88
const floating_point INCHES_TO_METERS
Definition unitutils.h:65
const floating_point SPEED_OF_LIGHT
Definition unitutils.h:51
const double KG_TO_LBS
Definition unitutils.h:71
const double LBS_TO_KG
Definition unitutils.h:70
const floating_point METERS_TO_KM
Definition unitutils.h:59
const floating_point METERS_TO_AU
Definition unitutils.h:56
const floating_point SECONDS_TO_MICROSECONDS
Definition unitutils.h:83
const double METERS_TO_NAUTICAL_MILES
Definition unitutils.h:67
const floating_point DAYS_TO_SECONDS
Definition unitutils.h:90
const floating_point METERS_TO_FEET
Definition unitutils.h:61
const floating_point BOLTZMANN_CONSTANT
Definition unitutils.h:52
const floating_point MICROSECONDS_TO_NANOSECONDS
Definition unitutils.h:85
const floating_point MINUTES_TO_SECONDS
Definition unitutils.h:87
const floating_point MICROSECONDS_TO_MILLISECONDS
Definition unitutils.h:86
const floating_point MILLISECONDS_TO_NANOSECONDS
Definition unitutils.h:81
const floating_point MILLIBAR_TO_PASCAL
Definition unitutils.h:96
const floating_point M_PI
Definition unitutils.h:32
const floating_point M_E
Definition unitutils.h:27
const floating_point M_PI_4
Definition unitutils.h:34
const floating_point M_1_PI
Definition unitutils.h:35
const floating_point M_LOG2E
Definition unitutils.h:28
const floating_point M_PI_2
Definition unitutils.h:33
const floating_point M_2_SQRTPI
Definition unitutils.h:37
const floating_point M_SQRT1_2
Definition unitutils.h:39
const floating_point M_2_PI
Definition unitutils.h:36
const floating_point M_LN2
Definition unitutils.h:30
const floating_point M_SQRT2
Definition unitutils.h:38
const floating_point M_LOG10E
Definition unitutils.h:29
const floating_point M_LN10
Definition unitutils.h:31