LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
QSpeed.hpp
Go to the documentation of this file.
1/*
2 * This code is a modified version of Benjamin Jurke's work in 2015. You can read his blog post
3 * here:
4 * https://benjaminjurke.com/content/articles/2015/compile-time-numerical-unit-dimension-checking/
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10#pragma once
11
15
16namespace okapi {
17QUANTITY_TYPE(0, 1, -1, 0, QSpeed)
18
19constexpr QSpeed mps = meter / second;
20constexpr QSpeed miph = mile / hour;
21constexpr QSpeed kmph = kilometer / hour;
22
23inline namespace literals {
24constexpr QSpeed operator"" _mps(long double x) {
25 return static_cast<double>(x) * mps;
26}
27constexpr QSpeed operator"" _miph(long double x) {
28 return static_cast<double>(x) * mile / hour;
29}
30constexpr QSpeed operator"" _kmph(long double x) {
31 return static_cast<double>(x) * kilometer / hour;
32}
33constexpr QSpeed operator"" _mps(unsigned long long int x) {
34 return static_cast<double>(x) * mps;
35}
36constexpr QSpeed operator"" _miph(unsigned long long int x) {
37 return static_cast<double>(x) * mile / hour;
38}
39constexpr QSpeed operator"" _kmph(unsigned long long int x) {
40 return static_cast<double>(x) * kilometer / hour;
41}
42} // namespace literals
43} // namespace okapi
#define QUANTITY_TYPE(_Mdim, _Ldim, _Tdim, _Adim, name)
Definition RQuantity.hpp:84
constexpr QLength kilometer
Definition QLength.hpp:21
constexpr QSpeed mps
Definition QSpeed.hpp:19
constexpr QTime hour
Definition QTime.hpp:20
constexpr QLength meter(1.0)
constexpr QSpeed miph
Definition QSpeed.hpp:20
@ x
Roll Axis.
constexpr QLength mile
Definition QLength.hpp:25
constexpr QTime second(1.0)
constexpr QSpeed kmph
Definition QSpeed.hpp:21