LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
QLength.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
13
14namespace okapi {
15QUANTITY_TYPE(0, 1, 0, 0, QLength)
16
17constexpr QLength meter(1.0); // SI base unit
18constexpr QLength decimeter = meter / 10;
19constexpr QLength centimeter = meter / 100;
20constexpr QLength millimeter = meter / 1000;
21constexpr QLength kilometer = 1000 * meter;
22constexpr QLength inch = 2.54 * centimeter;
23constexpr QLength foot = 12 * inch;
24constexpr QLength yard = 3 * foot;
25constexpr QLength mile = 5280 * foot;
26constexpr QLength tile = 24 * inch;
27
28inline namespace literals {
29constexpr QLength operator"" _mm(long double x) {
30 return static_cast<double>(x) * millimeter;
31}
32constexpr QLength operator"" _cm(long double x) {
33 return static_cast<double>(x) * centimeter;
34}
35constexpr QLength operator"" _m(long double x) {
36 return static_cast<double>(x) * meter;
37}
38constexpr QLength operator"" _km(long double x) {
39 return static_cast<double>(x) * kilometer;
40}
41constexpr QLength operator"" _mi(long double x) {
42 return static_cast<double>(x) * mile;
43}
44constexpr QLength operator"" _yd(long double x) {
45 return static_cast<double>(x) * yard;
46}
47constexpr QLength operator"" _ft(long double x) {
48 return static_cast<double>(x) * foot;
49}
50constexpr QLength operator"" _in(long double x) {
51 return static_cast<double>(x) * inch;
52}
53constexpr QLength operator"" _tile(long double x) {
54 return static_cast<double>(x) * tile;
55}
56constexpr QLength operator"" _mm(unsigned long long int x) {
57 return static_cast<double>(x) * millimeter;
58}
59constexpr QLength operator"" _cm(unsigned long long int x) {
60 return static_cast<double>(x) * centimeter;
61}
62constexpr QLength operator"" _m(unsigned long long int x) {
63 return static_cast<double>(x) * meter;
64}
65constexpr QLength operator"" _km(unsigned long long int x) {
66 return static_cast<double>(x) * kilometer;
67}
68constexpr QLength operator"" _mi(unsigned long long int x) {
69 return static_cast<double>(x) * mile;
70}
71constexpr QLength operator"" _yd(unsigned long long int x) {
72 return static_cast<double>(x) * yard;
73}
74constexpr QLength operator"" _ft(unsigned long long int x) {
75 return static_cast<double>(x) * foot;
76}
77constexpr QLength operator"" _in(unsigned long long int x) {
78 return static_cast<double>(x) * inch;
79}
80constexpr QLength operator"" _tile(unsigned long long int x) {
81 return static_cast<double>(x) * tile;
82}
83} // namespace literals
84} // namespace okapi
#define QUANTITY_TYPE(_Mdim, _Ldim, _Tdim, _Adim, name)
Definition RQuantity.hpp:84
constexpr QLength kilometer
Definition QLength.hpp:21
constexpr QLength tile
Definition QLength.hpp:26
constexpr QLength yard
Definition QLength.hpp:24
constexpr QLength meter(1.0)
constexpr QLength foot
Definition QLength.hpp:23
constexpr QLength inch
Definition QLength.hpp:22
constexpr QLength centimeter
Definition QLength.hpp:19
constexpr QLength millimeter
Definition QLength.hpp:20
@ x
Roll Axis.
constexpr QLength mile
Definition QLength.hpp:25
constexpr QLength decimeter
Definition QLength.hpp:18