mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[wpiutil] Split units.h into separate headers for each unit (#2551)
Closes #2508. Co-authored-by: Prateek Machiraju <prateek.machiraju@gmail.com>
This commit is contained in:
59
wpiutil/src/main/native/include/units/acceleration.h
Normal file
59
wpiutil/src/main/native/include/units/acceleration.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::acceleration
|
||||
* @brief namespace for unit types and containers representing acceleration
|
||||
* values
|
||||
* @details The SI unit for acceleration is `meters_per_second_squared`, and the
|
||||
* corresponding `base_unit` category is `acceleration_unit`.
|
||||
* @anchor accelerationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ACCELERATION_UNITS)
|
||||
UNIT_ADD(acceleration, meters_per_second_squared, meters_per_second_squared,
|
||||
mps_sq, unit<std::ratio<1>, units::category::acceleration_unit>)
|
||||
UNIT_ADD(acceleration, feet_per_second_squared, feet_per_second_squared, fps_sq,
|
||||
compound_unit<length::feet, inverse<squared<time::seconds>>>)
|
||||
UNIT_ADD(acceleration, standard_gravity, standard_gravity, SG,
|
||||
unit<std::ratio<980665, 100000>, meters_per_second_squared>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(acceleration)
|
||||
#endif
|
||||
|
||||
using namespace acceleration;
|
||||
} // namespace units
|
||||
59
wpiutil/src/main/native/include/units/angle.h
Normal file
59
wpiutil/src/main/native/include/units/angle.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::angle
|
||||
* @brief namespace for unit types and containers representing angle values
|
||||
* @details The SI unit for angle is `radians`, and the corresponding
|
||||
* `base_unit` category is`angle_unit`.
|
||||
* @anchor angleContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(angle, radian, radians, rad,
|
||||
unit<std::ratio<1>, units::category::angle_unit>)
|
||||
UNIT_ADD(angle, degree, degrees, deg,
|
||||
unit<std::ratio<1, 180>, radians, std::ratio<1>>)
|
||||
UNIT_ADD(angle, arcminute, arcminutes, arcmin, unit<std::ratio<1, 60>, degrees>)
|
||||
UNIT_ADD(angle, arcsecond, arcseconds, arcsec,
|
||||
unit<std::ratio<1, 60>, arcminutes>)
|
||||
UNIT_ADD(angle, milliarcsecond, milliarcseconds, mas, milli<arcseconds>)
|
||||
UNIT_ADD(angle, turn, turns, tr, unit<std::ratio<2>, radians, std::ratio<1>>)
|
||||
UNIT_ADD(angle, gradian, gradians, gon, unit<std::ratio<1, 400>, turns>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(angle)
|
||||
#endif
|
||||
|
||||
using namespace angle;
|
||||
} // namespace units
|
||||
61
wpiutil/src/main/native/include/units/angular_velocity.h
Normal file
61
wpiutil/src/main/native/include/units/angular_velocity.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/angle.h"
|
||||
#include "units/base.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::angular_velocity
|
||||
* @brief namespace for unit types and containers representing angular velocity
|
||||
* values
|
||||
* @details The SI unit for angular velocity is `radians_per_second`, and the
|
||||
* corresponding `base_unit` category is`angular_velocity_unit`.
|
||||
* @anchor angularVelocityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ANGULAR_VELOCITY_UNITS)
|
||||
UNIT_ADD(angular_velocity, radians_per_second, radians_per_second, rad_per_s,
|
||||
unit<std::ratio<1>, units::category::angular_velocity_unit>)
|
||||
UNIT_ADD(angular_velocity, degrees_per_second, degrees_per_second, deg_per_s,
|
||||
compound_unit<angle::degrees, inverse<time::seconds>>)
|
||||
UNIT_ADD(angular_velocity, revolutions_per_minute, revolutions_per_minute, rpm,
|
||||
unit<std::ratio<2, 60>, radians_per_second, std::ratio<1>>)
|
||||
UNIT_ADD(angular_velocity, milliarcseconds_per_year, milliarcseconds_per_year,
|
||||
mas_per_yr, compound_unit<angle::milliarcseconds, inverse<time::year>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(angular_velocity)
|
||||
#endif
|
||||
|
||||
using namespace angular_velocity;
|
||||
} // namespace units
|
||||
59
wpiutil/src/main/native/include/units/area.h
Normal file
59
wpiutil/src/main/native/include/units/area.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::area
|
||||
* @brief namespace for unit types and containers representing area values
|
||||
* @details The SI unit for area is `square_meters`, and the corresponding
|
||||
* `base_unit` category is `area_unit`.
|
||||
* @anchor areaContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_AREA_UNITS)
|
||||
UNIT_ADD(area, square_meter, square_meters, sq_m,
|
||||
unit<std::ratio<1>, units::category::area_unit>)
|
||||
UNIT_ADD(area, square_foot, square_feet, sq_ft, squared<length::feet>)
|
||||
UNIT_ADD(area, square_inch, square_inches, sq_in, squared<length::inch>)
|
||||
UNIT_ADD(area, square_mile, square_miles, sq_mi, squared<length::miles>)
|
||||
UNIT_ADD(area, square_kilometer, square_kilometers, sq_km,
|
||||
squared<length::kilometers>)
|
||||
UNIT_ADD(area, hectare, hectares, ha, unit<std::ratio<10000>, square_meters>)
|
||||
UNIT_ADD(area, acre, acres, acre, unit<std::ratio<43560>, square_feet>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(area)
|
||||
#endif
|
||||
|
||||
using namespace area;
|
||||
} // namespace units
|
||||
3366
wpiutil/src/main/native/include/units/base.h
Normal file
3366
wpiutil/src/main/native/include/units/base.h
Normal file
File diff suppressed because it is too large
Load Diff
54
wpiutil/src/main/native/include/units/capacitance.h
Normal file
54
wpiutil/src/main/native/include/units/capacitance.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::capacitance
|
||||
* @brief namespace for unit types and containers representing capacitance
|
||||
* values
|
||||
* @details The SI unit for capacitance is `farads`, and the corresponding
|
||||
* `base_unit` category is `capacitance_unit`.
|
||||
* @anchor capacitanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CAPACITANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
capacitance, farad, farads, F,
|
||||
unit<std::ratio<1>, units::category::capacitance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(capacitance)
|
||||
#endif
|
||||
|
||||
using namespace capacitance;
|
||||
} // namespace units
|
||||
56
wpiutil/src/main/native/include/units/charge.h
Normal file
56
wpiutil/src/main/native/include/units/charge.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/current.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::charge
|
||||
* @brief namespace for unit types and containers representing charge values
|
||||
* @details The SI unit for charge is `coulombs`, and the corresponding
|
||||
* `base_unit` category is `charge_unit`.
|
||||
* @anchor chargeContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CHARGE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(charge, coulomb, coulombs, C,
|
||||
unit<std::ratio<1>, units::category::charge_unit>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(charge, ampere_hour, ampere_hours, Ah,
|
||||
compound_unit<current::ampere, time::hours>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(charge)
|
||||
#endif
|
||||
|
||||
using namespace charge;
|
||||
} // namespace units
|
||||
59
wpiutil/src/main/native/include/units/concentration.h
Normal file
59
wpiutil/src/main/native/include/units/concentration.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::concentration
|
||||
* @brief namespace for unit types and containers representing concentration
|
||||
* values
|
||||
* @details The SI unit for concentration is `parts_per_million`, and the
|
||||
* corresponding `base_unit` category is `scalar_unit`.
|
||||
* @anchor concentrationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CONCENTRATION_UNITS)
|
||||
UNIT_ADD(concentration, ppm, parts_per_million, ppm,
|
||||
unit<std::ratio<1, 1000000>, units::category::scalar_unit>)
|
||||
UNIT_ADD(concentration, ppb, parts_per_billion, ppb,
|
||||
unit<std::ratio<1, 1000>, parts_per_million>)
|
||||
UNIT_ADD(concentration, ppt, parts_per_trillion, ppt,
|
||||
unit<std::ratio<1, 1000>, parts_per_billion>)
|
||||
UNIT_ADD(concentration, percent, percent, pct,
|
||||
unit<std::ratio<1, 100>, units::category::scalar_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(concentration)
|
||||
#endif
|
||||
|
||||
using namespace concentration;
|
||||
} // namespace units
|
||||
54
wpiutil/src/main/native/include/units/conductance.h
Normal file
54
wpiutil/src/main/native/include/units/conductance.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::conductance
|
||||
* @brief namespace for unit types and containers representing conductance
|
||||
* values
|
||||
* @details The SI unit for conductance is `siemens`, and the corresponding
|
||||
* `base_unit` category is `conductance_unit`.
|
||||
* @anchor conductanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CONDUCTANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
conductance, siemens, siemens, S,
|
||||
unit<std::ratio<1>, units::category::conductance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(conductance)
|
||||
#endif
|
||||
|
||||
using namespace conductance;
|
||||
} // namespace units
|
||||
113
wpiutil/src/main/native/include/units/constants.h
Normal file
113
wpiutil/src/main/native/include/units/constants.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/area.h"
|
||||
#include "units/capacitance.h"
|
||||
#include "units/charge.h"
|
||||
#include "units/current.h"
|
||||
#include "units/dimensionless.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/force.h"
|
||||
#include "units/impedance.h"
|
||||
#include "units/length.h"
|
||||
#include "units/magnetic_field_strength.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/power.h"
|
||||
#include "units/substance.h"
|
||||
#include "units/temperature.h"
|
||||
#include "units/time.h"
|
||||
#include "units/velocity.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @brief namespace for physical constants like PI and Avogadro's Number.
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS)
|
||||
namespace constants {
|
||||
/**
|
||||
* @name Unit Containers
|
||||
* @anchor constantContainers
|
||||
* @{
|
||||
*/
|
||||
using PI = unit<std::ratio<1>, dimensionless::scalar, std::ratio<1>>;
|
||||
|
||||
static constexpr const unit_t<PI> pi(
|
||||
1); ///< Ratio of a circle's circumference to its diameter.
|
||||
static constexpr const velocity::meters_per_second_t c(
|
||||
299792458.0); ///< Speed of light in vacuum.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<cubed<length::meters>, inverse<mass::kilogram>,
|
||||
inverse<squared<time::seconds>>>>
|
||||
G(6.67408e-11); ///< Newtonian constant of gravitation.
|
||||
static constexpr const unit_t<compound_unit<energy::joule, time::seconds>> h(
|
||||
6.626070040e-34); ///< Planck constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<force::newtons, inverse<squared<current::ampere>>>>
|
||||
mu0(pi * 4.0e-7 * force::newton_t(1) /
|
||||
units::math::cpow<2>(current::ampere_t(1))); ///< vacuum permeability.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<capacitance::farad, inverse<length::meter>>>
|
||||
epsilon0(1.0 / (mu0 * math::cpow<2>(c))); ///< vacuum permitivity.
|
||||
static constexpr const impedance::ohm_t Z0(
|
||||
mu0* c); ///< characteristic impedance of vacuum.
|
||||
static constexpr const unit_t<compound_unit<force::newtons, area::square_meter,
|
||||
inverse<squared<charge::coulomb>>>>
|
||||
k_e(1.0 / (4 * pi * epsilon0)); ///< Coulomb's constant.
|
||||
static constexpr const charge::coulomb_t e(
|
||||
1.6021766208e-19); ///< elementary charge.
|
||||
static constexpr const mass::kilogram_t m_e(
|
||||
9.10938356e-31); ///< electron mass.
|
||||
static constexpr const mass::kilogram_t m_p(1.672621898e-27); ///< proton mass.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<energy::joules, inverse<magnetic_field_strength::tesla>>>
|
||||
mu_B(e* h / (4 * pi * m_e)); ///< Bohr magneton.
|
||||
static constexpr const unit_t<inverse<substance::mol>> N_A(
|
||||
6.022140857e23); ///< Avagadro's Number.
|
||||
static constexpr const unit_t<compound_unit<
|
||||
energy::joules, inverse<temperature::kelvin>, inverse<substance::moles>>>
|
||||
R(8.3144598); ///< Gas constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<energy::joules, inverse<temperature::kelvin>>>
|
||||
k_B(R / N_A); ///< Boltzmann constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<charge::coulomb, inverse<substance::mol>>>
|
||||
F(N_A* e); ///< Faraday constant.
|
||||
static constexpr const unit_t<
|
||||
compound_unit<power::watts, inverse<area::square_meters>,
|
||||
inverse<squared<squared<temperature::kelvin>>>>>
|
||||
sigma((2 * math::cpow<5>(pi) * math::cpow<4>(R)) /
|
||||
(15 * math::cpow<3>(h) * math::cpow<2>(c) *
|
||||
math::cpow<4>(N_A))); ///< Stefan-Boltzmann constant.
|
||||
/** @} */
|
||||
} // namespace constants
|
||||
#endif
|
||||
} // namespace units
|
||||
53
wpiutil/src/main/native/include/units/current.h
Normal file
53
wpiutil/src/main/native/include/units/current.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::current
|
||||
* @brief namespace for unit types and containers representing current values
|
||||
* @details The SI unit for current is `amperes`, and the corresponding
|
||||
* `base_unit` category is `current_unit`.
|
||||
* @anchor currentContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_CURRENT_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
current, ampere, amperes, A,
|
||||
unit<std::ratio<1>, units::category::current_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(current)
|
||||
#endif
|
||||
|
||||
using namespace current;
|
||||
} // namespace units
|
||||
17
wpiutil/src/main/native/include/units/curvature.h
Normal file
17
wpiutil/src/main/native/include/units/curvature.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/angle.h"
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
using curvature_t = units::unit_t<
|
||||
units::compound_unit<units::radians, units::inverse<units::meters>>>;
|
||||
} // namespace units
|
||||
55
wpiutil/src/main/native/include/units/data.h
Normal file
55
wpiutil/src/main/native/include/units/data.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::data
|
||||
* @brief namespace for unit types and containers representing data values
|
||||
* @details The base unit for data is `bytes`, and the corresponding `base_unit`
|
||||
* category is `data_unit`.
|
||||
* @anchor dataContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_DATA_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(
|
||||
data, byte, bytes, B, unit<std::ratio<1>, units::category::data_unit>)
|
||||
UNIT_ADD(data, exabyte, exabytes, EB, unit<std::ratio<1000>, petabytes>)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(data, bit, bits, b,
|
||||
unit<std::ratio<1, 8>, byte>)
|
||||
UNIT_ADD(data, exabit, exabits, Eb, unit<std::ratio<1000>, petabits>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(data)
|
||||
#endif
|
||||
|
||||
using namespace data;
|
||||
} // namespace units
|
||||
60
wpiutil/src/main/native/include/units/data_transfer_rate.h
Normal file
60
wpiutil/src/main/native/include/units/data_transfer_rate.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::data_transfer_rate
|
||||
* @brief namespace for unit types and containers representing data values
|
||||
* @details The base unit for data is `bytes`, and the corresponding `base_unit`
|
||||
* category is `data_unit`.
|
||||
* @anchor dataContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_DATA_TRANSFER_RATE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(
|
||||
data_transfer_rate, bytes_per_second, bytes_per_second, Bps,
|
||||
unit<std::ratio<1>, units::category::data_transfer_rate_unit>)
|
||||
UNIT_ADD(data_transfer_rate, exabytes_per_second, exabytes_per_second, EBps,
|
||||
unit<std::ratio<1000>, petabytes_per_second>)
|
||||
UNIT_ADD_WITH_METRIC_AND_BINARY_PREFIXES(
|
||||
data_transfer_rate, bits_per_second, bits_per_second, bps,
|
||||
unit<std::ratio<1, 8>, bytes_per_second>)
|
||||
UNIT_ADD(data_transfer_rate, exabits_per_second, exabits_per_second, Ebps,
|
||||
unit<std::ratio<1000>, petabits_per_second>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(data_transfer_rate)
|
||||
#endif
|
||||
|
||||
using namespace data_transfer_rate;
|
||||
} // namespace units
|
||||
73
wpiutil/src/main/native/include/units/density.h
Normal file
73
wpiutil/src/main/native/include/units/density.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/volume.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::density
|
||||
* @brief namespace for unit types and containers representing density values
|
||||
* @details The SI unit for density is `kilograms_per_cubic_meter`, and the
|
||||
* corresponding `base_unit` category is `density_unit`.
|
||||
* @anchor densityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_DENSITY_UNITS)
|
||||
UNIT_ADD(density, kilograms_per_cubic_meter, kilograms_per_cubic_meter,
|
||||
kg_per_cu_m, unit<std::ratio<1>, units::category::density_unit>)
|
||||
UNIT_ADD(density, grams_per_milliliter, grams_per_milliliter, g_per_mL,
|
||||
compound_unit<mass::grams, inverse<volume::milliliter>>)
|
||||
UNIT_ADD(density, kilograms_per_liter, kilograms_per_liter, kg_per_L,
|
||||
unit<std::ratio<1>,
|
||||
compound_unit<mass::grams, inverse<volume::milliliter>>>)
|
||||
UNIT_ADD(density, ounces_per_cubic_foot, ounces_per_cubic_foot, oz_per_cu_ft,
|
||||
compound_unit<mass::ounces, inverse<volume::cubic_foot>>)
|
||||
UNIT_ADD(density, ounces_per_cubic_inch, ounces_per_cubic_inch, oz_per_cu_in,
|
||||
compound_unit<mass::ounces, inverse<volume::cubic_inch>>)
|
||||
UNIT_ADD(density, ounces_per_gallon, ounces_per_gallon, oz_per_gal,
|
||||
compound_unit<mass::ounces, inverse<volume::gallon>>)
|
||||
UNIT_ADD(density, pounds_per_cubic_foot, pounds_per_cubic_foot, lb_per_cu_ft,
|
||||
compound_unit<mass::pounds, inverse<volume::cubic_foot>>)
|
||||
UNIT_ADD(density, pounds_per_cubic_inch, pounds_per_cubic_inch, lb_per_cu_in,
|
||||
compound_unit<mass::pounds, inverse<volume::cubic_inch>>)
|
||||
UNIT_ADD(density, pounds_per_gallon, pounds_per_gallon, lb_per_gal,
|
||||
compound_unit<mass::pounds, inverse<volume::gallon>>)
|
||||
UNIT_ADD(density, slugs_per_cubic_foot, slugs_per_cubic_foot, slug_per_cu_ft,
|
||||
compound_unit<mass::slugs, inverse<volume::cubic_foot>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(density)
|
||||
#endif
|
||||
|
||||
using namespace density;
|
||||
} // namespace units
|
||||
39
wpiutil/src/main/native/include/units/dimensionless.h
Normal file
39
wpiutil/src/main/native/include/units/dimensionless.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
using dimensionless::dB_t;
|
||||
using dimensionless::dimensionless_t;
|
||||
using dimensionless::scalar;
|
||||
using dimensionless::scalar_t;
|
||||
} // namespace units
|
||||
68
wpiutil/src/main/native/include/units/energy.h
Normal file
68
wpiutil/src/main/native/include/units/energy.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::energy
|
||||
* @brief namespace for unit types and containers representing energy values
|
||||
* @details The SI unit for energy is `joules`, and the corresponding
|
||||
* `base_unit` category is `energy_unit`.
|
||||
* @anchor energyContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ENERGY_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(energy, joule, joules, J,
|
||||
unit<std::ratio<1>, units::category::energy_unit>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(energy, calorie, calories, cal,
|
||||
unit<std::ratio<4184, 1000>, joules>)
|
||||
UNIT_ADD(energy, kilowatt_hour, kilowatt_hours, kWh,
|
||||
unit<std::ratio<36, 10>, megajoules>)
|
||||
UNIT_ADD(energy, watt_hour, watt_hours, Wh,
|
||||
unit<std::ratio<1, 1000>, kilowatt_hours>)
|
||||
UNIT_ADD(energy, british_thermal_unit, british_thermal_units, BTU,
|
||||
unit<std::ratio<105505585262, 100000000>, joules>)
|
||||
UNIT_ADD(energy, british_thermal_unit_iso, british_thermal_units_iso, BTU_iso,
|
||||
unit<std::ratio<1055056, 1000>, joules>)
|
||||
UNIT_ADD(energy, british_thermal_unit_59, british_thermal_units_59, BTU59,
|
||||
unit<std::ratio<1054804, 1000>, joules>)
|
||||
UNIT_ADD(energy, therm, therms, thm,
|
||||
unit<std::ratio<100000>, british_thermal_units_59>)
|
||||
UNIT_ADD(energy, foot_pound, foot_pounds, ftlbf,
|
||||
unit<std::ratio<13558179483314004, 10000000000000000>, joules>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(energy)
|
||||
#endif
|
||||
|
||||
using namespace energy;
|
||||
} // namespace units
|
||||
65
wpiutil/src/main/native/include/units/force.h
Normal file
65
wpiutil/src/main/native/include/units/force.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/acceleration.h"
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/mass.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::force
|
||||
* @brief namespace for unit types and containers representing force values
|
||||
* @details The SI unit for force is `newtons`, and the corresponding
|
||||
* `base_unit` category is `force_unit`.
|
||||
* @anchor forceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_FORCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(force, newton, newtons, N,
|
||||
unit<std::ratio<1>, units::category::force_unit>)
|
||||
UNIT_ADD(
|
||||
force, pound, pounds, lbf,
|
||||
compound_unit<mass::slug, length::foot, inverse<squared<time::seconds>>>)
|
||||
UNIT_ADD(force, dyne, dynes, dyn, unit<std::ratio<1, 100000>, newtons>)
|
||||
UNIT_ADD(force, kilopond, kiloponds, kp,
|
||||
compound_unit<acceleration::standard_gravity, mass::kilograms>)
|
||||
UNIT_ADD(
|
||||
force, poundal, poundals, pdl,
|
||||
compound_unit<mass::pound, length::foot, inverse<squared<time::seconds>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(force)
|
||||
#endif
|
||||
|
||||
using force::newton_t;
|
||||
using force::newtons;
|
||||
} // namespace units
|
||||
53
wpiutil/src/main/native/include/units/frequency.h
Normal file
53
wpiutil/src/main/native/include/units/frequency.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::frequency
|
||||
* @brief namespace for unit types and containers representing frequency values
|
||||
* @details The SI unit for frequency is `hertz`, and the corresponding
|
||||
* `base_unit` category is `frequency_unit`.
|
||||
* @anchor frequencyContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_FREQUENCY_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
frequency, hertz, hertz, Hz,
|
||||
unit<std::ratio<1>, units::category::frequency_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(frequency)
|
||||
#endif
|
||||
|
||||
using namespace frequency;
|
||||
} // namespace units
|
||||
64
wpiutil/src/main/native/include/units/illuminance.h
Normal file
64
wpiutil/src/main/native/include/units/illuminance.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/luminous_flux.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::illuminance
|
||||
* @brief namespace for unit types and containers representing illuminance
|
||||
* values
|
||||
* @details The SI unit for illuminance is `luxes`, and the corresponding
|
||||
* `base_unit` category is `illuminance_unit`.
|
||||
* @anchor illuminanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_ILLUMINANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
illuminance, lux, luxes, lx,
|
||||
unit<std::ratio<1>, units::category::illuminance_unit>)
|
||||
UNIT_ADD(illuminance, footcandle, footcandles, fc,
|
||||
compound_unit<luminous_flux::lumen, inverse<squared<length::foot>>>)
|
||||
UNIT_ADD(illuminance, lumens_per_square_inch, lumens_per_square_inch,
|
||||
lm_per_in_sq,
|
||||
compound_unit<luminous_flux::lumen, inverse<squared<length::inch>>>)
|
||||
UNIT_ADD(
|
||||
illuminance, phot, phots, ph,
|
||||
compound_unit<luminous_flux::lumens, inverse<squared<length::centimeter>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(illuminance)
|
||||
#endif
|
||||
|
||||
using namespace illuminance;
|
||||
} // namespace units
|
||||
53
wpiutil/src/main/native/include/units/impedance.h
Normal file
53
wpiutil/src/main/native/include/units/impedance.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::impedance
|
||||
* @brief namespace for unit types and containers representing impedance values
|
||||
* @details The SI unit for impedance is `ohms`, and the corresponding
|
||||
* `base_unit` category is `impedance_unit`.
|
||||
* @anchor impedanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_IMPEDANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
impedance, ohm, ohms, Ohm,
|
||||
unit<std::ratio<1>, units::category::impedance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(impedance)
|
||||
#endif
|
||||
|
||||
using namespace impedance;
|
||||
} // namespace units
|
||||
53
wpiutil/src/main/native/include/units/inductance.h
Normal file
53
wpiutil/src/main/native/include/units/inductance.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::inductance
|
||||
* @brief namespace for unit types and containers representing inductance values
|
||||
* @details The SI unit for inductance is `henrys`, and the corresponding
|
||||
* `base_unit` category is `inductance_unit`.
|
||||
* @anchor inductanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_INDUCTANCE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
inductance, henry, henries, H,
|
||||
unit<std::ratio<1>, units::category::inductance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(inductance)
|
||||
#endif
|
||||
|
||||
using namespace inductance;
|
||||
} // namespace units
|
||||
75
wpiutil/src/main/native/include/units/length.h
Normal file
75
wpiutil/src/main/native/include/units/length.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::length
|
||||
* @brief namespace for unit types and containers representing length values
|
||||
* @details The SI unit for length is `meters`, and the corresponding
|
||||
* `base_unit` category is `length_unit`.
|
||||
* @anchor lengthContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_LENGTH_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(length, meter, meters, m,
|
||||
unit<std::ratio<1>, units::category::length_unit>)
|
||||
UNIT_ADD(length, foot, feet, ft, unit<std::ratio<381, 1250>, meters>)
|
||||
UNIT_ADD(length, mil, mils, mil, unit<std::ratio<1000>, feet>)
|
||||
UNIT_ADD(length, inch, inches, in, unit<std::ratio<1, 12>, feet>)
|
||||
UNIT_ADD(length, mile, miles, mi, unit<std::ratio<5280>, feet>)
|
||||
UNIT_ADD(length, nauticalMile, nauticalMiles, nmi,
|
||||
unit<std::ratio<1852>, meters>)
|
||||
UNIT_ADD(length, astronicalUnit, astronicalUnits, au,
|
||||
unit<std::ratio<149597870700>, meters>)
|
||||
UNIT_ADD(length, lightyear, lightyears, ly,
|
||||
unit<std::ratio<9460730472580800>, meters>)
|
||||
UNIT_ADD(length, parsec, parsecs, pc,
|
||||
unit<std::ratio<648000>, astronicalUnits, std::ratio<-1>>)
|
||||
UNIT_ADD(length, angstrom, angstroms, angstrom,
|
||||
unit<std::ratio<1, 10>, nanometers>)
|
||||
UNIT_ADD(length, cubit, cubits, cbt, unit<std::ratio<18>, inches>)
|
||||
UNIT_ADD(length, fathom, fathoms, ftm, unit<std::ratio<6>, feet>)
|
||||
UNIT_ADD(length, chain, chains, ch, unit<std::ratio<66>, feet>)
|
||||
UNIT_ADD(length, furlong, furlongs, fur, unit<std::ratio<10>, chains>)
|
||||
UNIT_ADD(length, hand, hands, hand, unit<std::ratio<4>, inches>)
|
||||
UNIT_ADD(length, league, leagues, lea, unit<std::ratio<3>, miles>)
|
||||
UNIT_ADD(length, nauticalLeague, nauticalLeagues, nl,
|
||||
unit<std::ratio<3>, nauticalMiles>)
|
||||
UNIT_ADD(length, yard, yards, yd, unit<std::ratio<3>, feet>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(length)
|
||||
#endif
|
||||
|
||||
using namespace length;
|
||||
} // namespace units
|
||||
54
wpiutil/src/main/native/include/units/luminous_flux.h
Normal file
54
wpiutil/src/main/native/include/units/luminous_flux.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::luminous_flux
|
||||
* @brief namespace for unit types and containers representing luminous_flux
|
||||
* values
|
||||
* @details The SI unit for luminous_flux is `lumens`, and the corresponding
|
||||
* `base_unit` category is `luminous_flux_unit`.
|
||||
* @anchor luminousFluxContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_LUMINOUS_FLUX_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
luminous_flux, lumen, lumens, lm,
|
||||
unit<std::ratio<1>, units::category::luminous_flux_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(luminous_flux)
|
||||
#endif
|
||||
|
||||
using namespace luminous_flux;
|
||||
} // namespace units
|
||||
54
wpiutil/src/main/native/include/units/luminous_intensity.h
Normal file
54
wpiutil/src/main/native/include/units/luminous_intensity.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::luminous_intensity
|
||||
* @brief namespace for unit types and containers representing
|
||||
* luminous_intensity values
|
||||
* @details The SI unit for luminous_intensity is `candelas`, and the
|
||||
* corresponding `base_unit` category is `luminous_intensity_unit`.
|
||||
* @anchor luminousIntensityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_LUMINOUS_INTENSITY_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
luminous_intensity, candela, candelas, cd,
|
||||
unit<std::ratio<1>, units::category::luminous_intensity_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(luminous_intensity)
|
||||
#endif
|
||||
|
||||
using namespace luminous_intensity;
|
||||
} // namespace units
|
||||
@@ -0,0 +1,62 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/magnetic_flux.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::magnetic_field_strength
|
||||
* @brief namespace for unit types and containers representing
|
||||
* magnetic_field_strength values
|
||||
* @details The SI unit for magnetic_field_strength is `teslas`, and the
|
||||
* corresponding `base_unit` category is
|
||||
* `magnetic_field_strength_unit`.
|
||||
* @anchor magneticFieldStrengthContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
// Unfortunately `_T` is a WINAPI macro, so we have to use `_Te` as the tesla
|
||||
// abbreviation.
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_MAGNETIC_FIELD_STRENGTH_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
magnetic_field_strength, tesla, teslas, Te,
|
||||
unit<std::ratio<1>, units::category::magnetic_field_strength_unit>)
|
||||
UNIT_ADD(
|
||||
magnetic_field_strength, gauss, gauss, G,
|
||||
compound_unit<magnetic_flux::maxwell, inverse<squared<length::centimeter>>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(magnetic_field_strength)
|
||||
#endif
|
||||
|
||||
using namespace magnetic_field_strength;
|
||||
} // namespace units
|
||||
56
wpiutil/src/main/native/include/units/magnetic_flux.h
Normal file
56
wpiutil/src/main/native/include/units/magnetic_flux.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::magnetic_flux
|
||||
* @brief namespace for unit types and containers representing magnetic_flux
|
||||
* values
|
||||
* @details The SI unit for magnetic_flux is `webers`, and the corresponding
|
||||
* `base_unit` category is `magnetic_flux_unit`.
|
||||
* @anchor magneticFluxContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_MAGNETIC_FLUX_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
magnetic_flux, weber, webers, Wb,
|
||||
unit<std::ratio<1>, units::category::magnetic_flux_unit>)
|
||||
UNIT_ADD(magnetic_flux, maxwell, maxwells, Mx,
|
||||
unit<std::ratio<1, 100000000>, webers>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(magnetic_flux)
|
||||
#endif
|
||||
|
||||
using namespace magnetic_flux;
|
||||
} // namespace units
|
||||
61
wpiutil/src/main/native/include/units/mass.h
Normal file
61
wpiutil/src/main/native/include/units/mass.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::mass
|
||||
* @brief namespace for unit types and containers representing mass values
|
||||
* @details The SI unit for mass is `kilograms`, and the corresponding
|
||||
* `base_unit` category is `mass_unit`.
|
||||
* @anchor massContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_MASS_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
mass, gram, grams, g, unit<std::ratio<1, 1000>, units::category::mass_unit>)
|
||||
UNIT_ADD(mass, metric_ton, metric_tons, t, unit<std::ratio<1000>, kilograms>)
|
||||
UNIT_ADD(mass, pound, pounds, lb,
|
||||
unit<std::ratio<45359237, 100000000>, kilograms>)
|
||||
UNIT_ADD(mass, long_ton, long_tons, ln_t, unit<std::ratio<2240>, pounds>)
|
||||
UNIT_ADD(mass, short_ton, short_tons, sh_t, unit<std::ratio<2000>, pounds>)
|
||||
UNIT_ADD(mass, stone, stone, st, unit<std::ratio<14>, pounds>)
|
||||
UNIT_ADD(mass, ounce, ounces, oz, unit<std::ratio<1, 16>, pounds>)
|
||||
UNIT_ADD(mass, carat, carats, ct, unit<std::ratio<200>, milligrams>)
|
||||
UNIT_ADD(mass, slug, slugs, slug,
|
||||
unit<std::ratio<145939029, 10000000>, kilograms>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(mass)
|
||||
#endif
|
||||
|
||||
using namespace mass;
|
||||
} // namespace units
|
||||
758
wpiutil/src/main/native/include/units/math.h
Normal file
758
wpiutil/src/main/native/include/units/math.h
Normal file
@@ -0,0 +1,758 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "units/angle.h"
|
||||
#include "units/base.h"
|
||||
#include "units/dimensionless.h"
|
||||
|
||||
namespace units {
|
||||
//----------------------------------
|
||||
// UNIT-ENABLED CMATH FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @brief namespace for unit-enabled versions of the `<cmath>` library
|
||||
* @details Includes trigonometric functions, exponential/log functions,
|
||||
* rounding functions, etc.
|
||||
* @sa See `unit_t` for more information on unit type containers.
|
||||
*/
|
||||
namespace math {
|
||||
//----------------------------------
|
||||
// TRIGONOMETRIC FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute cosine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the cosine of
|
||||
* @returns Returns the cosine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t cos(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::cos(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute sine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the since of
|
||||
* @returns Returns the sine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t sin(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::sin(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute tangent
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the tangent of
|
||||
* @returns Returns the tangent of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t tan(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::tan(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc cosine
|
||||
* @details Returns the principal value of the arc cosine of x, expressed in
|
||||
* radians.
|
||||
* @param[in] x Value whose arc cosine is computed, in the interval [-1,+1].
|
||||
* @returns Principal arc cosine of x, in the interval [0,pi] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t acos(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::acos(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc sine
|
||||
* @details Returns the principal value of the arc sine of x, expressed in
|
||||
* radians.
|
||||
* @param[in] x Value whose arc sine is computed, in the interval [-1,+1].
|
||||
* @returns Principal arc sine of x, in the interval [-pi/2,+pi/2] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t asin(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::asin(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc tangent
|
||||
* @details Returns the principal value of the arc tangent of x, expressed in
|
||||
* radians. Notice that because of the sign ambiguity, the function
|
||||
* cannot determine with certainty in which quadrant the angle falls
|
||||
* only by its tangent value. See atan2 for an alternative that takes a
|
||||
* fractional argument instead.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] x Value whose arc tangent is computed, in the interval [-1,+1].
|
||||
* @returns Principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t atan(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::atan(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc tangent with two parameters
|
||||
* @details To compute the value, the function takes into account the sign of
|
||||
* both arguments in order to determine the quadrant.
|
||||
* @param[in] y y-component of the triangle expressed.
|
||||
* @param[in] x x-component of the triangle expressed.
|
||||
* @returns Returns the principal value of the arc tangent of <i>y/x</i>,
|
||||
* expressed in radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class Y, class X>
|
||||
angle::radian_t atan2(const Y y, const X x) noexcept {
|
||||
static_assert(traits::is_dimensionless_unit<decltype(y / x)>::value,
|
||||
"The quantity y/x must yield a dimensionless ratio.");
|
||||
|
||||
// X and Y could be different length units, so normalize them
|
||||
return angle::radian_t(
|
||||
std::atan2(y.template convert<
|
||||
typename units::traits::unit_t_traits<X>::unit_type>()(),
|
||||
x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------
|
||||
// HYPERBOLIC TRIG FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute hyperbolic cosine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the hyperbolic cosine of
|
||||
* @returns Returns the hyperbolic cosine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t cosh(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::cosh(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute hyperbolic sine
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the hyperbolic sine of
|
||||
* @returns Returns the hyperbolic sine of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t sinh(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::sinh(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute hyperbolic tangent
|
||||
* @details The input value can be in any unit of angle, including radians or
|
||||
* degrees.
|
||||
* @tparam AngleUnit any `unit_t` type of `category::angle_unit`.
|
||||
* @param[in] angle angle to compute the hyperbolic tangent of
|
||||
* @returns Returns the hyperbolic tangent of <i>angle</i>
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class AngleUnit>
|
||||
dimensionless::scalar_t tanh(const AngleUnit angle) noexcept {
|
||||
static_assert(
|
||||
traits::is_angle_unit<AngleUnit>::value,
|
||||
"Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(
|
||||
std::tanh(angle.template convert<angle::radian>()()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc hyperbolic cosine
|
||||
* @details Returns the nonnegative arc hyperbolic cosine of x, expressed in
|
||||
* radians.
|
||||
* @param[in] x Value whose arc hyperbolic cosine is computed. If the argument
|
||||
* is less than 1, a domain error occurs.
|
||||
* @returns Nonnegative arc hyperbolic cosine of x, in the interval
|
||||
* [0,+INFINITY] radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t acosh(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::acosh(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc hyperbolic sine
|
||||
* @details Returns the arc hyperbolic sine of x, expressed in radians.
|
||||
* @param[in] x Value whose arc hyperbolic sine is computed.
|
||||
* @returns Arc hyperbolic sine of x, in radians.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t asinh(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::asinh(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute arc hyperbolic tangent
|
||||
* @details Returns the arc hyperbolic tangent of x, expressed in radians.
|
||||
* @param[in] x Value whose arc hyperbolic tangent is computed, in the interval
|
||||
* [-1,+1]. If the argument is out of this interval, a domain error
|
||||
* occurs. For values of -1 and +1, a pole error may occur.
|
||||
* @returns units::angle::radian_t
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
|
||||
template <class ScalarUnit>
|
||||
angle::radian_t atanh(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return angle::radian_t(std::atanh(x()));
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------
|
||||
// TRANSCENDENTAL FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
// it makes NO SENSE to put dimensioned units into a transcendental function,
|
||||
// and if you think it does you are demonstrably wrong.
|
||||
// https://en.wikipedia.org/wiki/Transcendental_function#Dimensional_analysis
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute exponential function
|
||||
* @details Returns the base-e exponential function of x, which is e raised to
|
||||
* the power x: ex.
|
||||
* @param[in] x scalar value of the exponent.
|
||||
* @returns Exponential value of x.
|
||||
* If the magnitude of the result is too large to be represented by a
|
||||
* value of the return type, the function returns HUGE_VAL (or
|
||||
* HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range
|
||||
* error occurs.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t exp(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::exp(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute natural logarithm
|
||||
* @details Returns the natural logarithm of x.
|
||||
* @param[in] x scalar value whose logarithm is calculated. If the argument is
|
||||
* negative, a domain error occurs.
|
||||
* @sa log10 for more common base-10 logarithms
|
||||
* @returns Natural logarithm of x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute common logarithm
|
||||
* @details Returns the common (base-10) logarithm of x.
|
||||
* @param[in] x Value whose logarithm is calculated. If the argument is
|
||||
* negative, a domain error occurs.
|
||||
* @returns Common logarithm of x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log10(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log10(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Break into fractional and integral parts.
|
||||
* @details The integer part is stored in the object pointed by intpart, and the
|
||||
* fractional part is returned by the function. Both parts have the
|
||||
* same sign as x.
|
||||
* @param[in] x scalar value to break into parts.
|
||||
* @param[in] intpart Pointer to an object (of the same type as x) where the
|
||||
* integral part is stored with the same sign as x.
|
||||
* @returns The fractional part of x, with the same sign.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t modf(const ScalarUnit x, ScalarUnit* intpart) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
|
||||
UNIT_LIB_DEFAULT_TYPE intp;
|
||||
dimensionless::scalar_t fracpart =
|
||||
dimensionless::scalar_t(std::modf(x(), &intp));
|
||||
*intpart = intp;
|
||||
return fracpart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute binary exponential function
|
||||
* @details Returns the base-2 exponential function of x, which is 2 raised to
|
||||
* the power x: 2^x. 2param[in] x Value of the exponent.
|
||||
* @returns 2 raised to the power of x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t exp2(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::exp2(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute exponential minus one
|
||||
* @details Returns e raised to the power x minus one: e^x-1. For small
|
||||
* magnitude values of x, expm1 may be more accurate than exp(x)-1.
|
||||
* @param[in] x Value of the exponent.
|
||||
* @returns e raised to the power of x, minus one.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t expm1(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::expm1(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute logarithm plus one
|
||||
* @details Returns the natural logarithm of one plus x. For small magnitude
|
||||
* values of x, logp1 may be more accurate than log(1+x).
|
||||
* @param[in] x Value whose logarithm is calculated. If the argument is less
|
||||
* than -1, a domain error occurs.
|
||||
* @returns The natural logarithm of (1+x).
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log1p(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log1p(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute binary logarithm
|
||||
* @details Returns the binary (base-2) logarithm of x.
|
||||
* @param[in] x Value whose logarithm is calculated. If the argument is
|
||||
* negative, a domain error occurs.
|
||||
* @returns The binary logarithm of x: log2x.
|
||||
*/
|
||||
template <class ScalarUnit>
|
||||
dimensionless::scalar_t log2(const ScalarUnit x) noexcept {
|
||||
static_assert(
|
||||
traits::is_dimensionless_unit<ScalarUnit>::value,
|
||||
"Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
|
||||
return dimensionless::scalar_t(std::log2(x()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// POWER FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/* pow is implemented earlier in the library since a lot of the unit definitions
|
||||
* depend on it */
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief computes the square root of <i>value</i>
|
||||
* @details Only implemented for linear_scale units.
|
||||
* @param[in] value `unit_t` derived type to compute the square root of.
|
||||
* @returns new unit_t, whose units are the square root of value's.
|
||||
* E.g. if values had units of `square_meter`, then the return type
|
||||
* will have units of `meter`.
|
||||
* @note `sqrt` provides a _rational approximation_ of the square root of
|
||||
* <i>value</i>. In some cases, _both_ the returned value _and_ conversion
|
||||
* factor of the returned unit type may have errors no larger than
|
||||
* `1e-10`.
|
||||
*/
|
||||
template <
|
||||
class UnitType,
|
||||
std::enable_if_t<units::traits::has_linear_scale<UnitType>::value, int> = 0>
|
||||
inline auto sqrt(const UnitType& value) noexcept -> unit_t<
|
||||
square_root<typename units::traits::unit_t_traits<UnitType>::unit_type>,
|
||||
typename units::traits::unit_t_traits<UnitType>::underlying_type,
|
||||
linear_scale> {
|
||||
return unit_t<
|
||||
square_root<typename units::traits::unit_t_traits<UnitType>::unit_type>,
|
||||
typename units::traits::unit_t_traits<UnitType>::underlying_type,
|
||||
linear_scale>(std::sqrt(value()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Computes the square root of the sum-of-squares of x and y.
|
||||
* @details Only implemented for linear_scale units.
|
||||
* @param[in] x unit_t type value
|
||||
* @param[in] y unit_t type value
|
||||
* @returns square root of the sum-of-squares of x and y in the same units as x.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
std::enable_if_t<
|
||||
units::traits::has_linear_scale<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
int> = 0>
|
||||
inline UnitTypeLhs hypot(const UnitTypeLhs& x, const UnitTypeRhs& y) {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of hypot() function are not compatible units.");
|
||||
return UnitTypeLhs(std::hypot(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// ROUNDING FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Round up value
|
||||
* @details Rounds x upward, returning the smallest integral value that is not
|
||||
* less than x.
|
||||
* @param[in] x Unit value to round up.
|
||||
* @returns The smallest integral value that is not less than x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType ceil(const UnitType x) noexcept {
|
||||
return UnitType(std::ceil(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Round down value
|
||||
* @details Rounds x downward, returning the largest integral value that is not
|
||||
* greater than x.
|
||||
* @param[in] x Unit value to round down.
|
||||
* @returns The value of x rounded downward.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType floor(const UnitType x) noexcept {
|
||||
return UnitType(std::floor(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute remainder of division
|
||||
* @details Returns the floating-point remainder of numer/denom (rounded towards
|
||||
* zero).
|
||||
* @param[in] numer Value of the quotient numerator.
|
||||
* @param[in] denom Value of the quotient denominator.
|
||||
* @returns The remainder of dividing the arguments.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fmod(const UnitTypeLhs numer, const UnitTypeRhs denom) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fmod() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fmod(
|
||||
numer(),
|
||||
denom.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Truncate value
|
||||
* @details Rounds x toward zero, returning the nearest integral value that is
|
||||
* not larger in magnitude than x. Effectively rounds towards 0.
|
||||
* @param[in] x Value to truncate
|
||||
* @returns The nearest integral value that is not larger in magnitude than x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType trunc(const UnitType x) noexcept {
|
||||
return UnitType(std::trunc(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Round to nearest
|
||||
* @details Returns the integral value that is nearest to x, with halfway cases
|
||||
* rounded away from zero.
|
||||
* @param[in] x value to round.
|
||||
* @returns The value of x rounded to the nearest integral.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType round(const UnitType x) noexcept {
|
||||
return UnitType(std::round(x()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// FLOATING POINT MANIPULATION
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Copy sign
|
||||
* @details Returns a value with the magnitude and dimension of x, and the sign
|
||||
* of y. Values x and y do not have to be compatible units.
|
||||
* @param[in] x Value with the magnitude of the resulting value.
|
||||
* @param[in] y Value with the sign of the resulting value.
|
||||
* @returns value with the magnitude and dimension of x, and the sign of y.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs copysign(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
return UnitTypeLhs(std::copysign(
|
||||
x(), y())); // no need for conversion to get the correct sign.
|
||||
}
|
||||
|
||||
/// Overload to copy the sign from a raw double
|
||||
template <class UnitTypeLhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value>>
|
||||
UnitTypeLhs copysign(const UnitTypeLhs x,
|
||||
const UNIT_LIB_DEFAULT_TYPE y) noexcept {
|
||||
return UnitTypeLhs(std::copysign(x(), y));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// MIN / MAX / DIFFERENCE
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Positive difference
|
||||
* @details The function returns x-y if x>y, and zero otherwise, in the same
|
||||
* units as x. Values x and y do not have to be the same type of units,
|
||||
* but they do have to be compatible.
|
||||
* @param[in] x Values whose difference is calculated.
|
||||
* @param[in] y Values whose difference is calculated.
|
||||
* @returns The positive difference between x and y.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fdim(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fdim() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fdim(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Maximum value
|
||||
* @details Returns the larger of its arguments: either x or y, in the same
|
||||
* units as x. Values x and y do not have to be the same type of units,
|
||||
* but they do have to be compatible.
|
||||
* @param[in] x Values among which the function selects a maximum.
|
||||
* @param[in] y Values among which the function selects a maximum.
|
||||
* @returns The maximum numeric value of its arguments.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fmax(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fmax() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fmax(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Minimum value
|
||||
* @details Returns the smaller of its arguments: either x or y, in the same
|
||||
* units as x. If one of the arguments in a NaN, the other is returned.
|
||||
* Values x and y do not have to be the same type of units, but they do
|
||||
* have to be compatible.
|
||||
* @param[in] x Values among which the function selects a minimum.
|
||||
* @param[in] y Values among which the function selects a minimum.
|
||||
* @returns The minimum numeric value of its arguments.
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitTypeRhs,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitTypeRhs>::value>>
|
||||
UnitTypeLhs fmin(const UnitTypeLhs x, const UnitTypeRhs y) noexcept {
|
||||
static_assert(traits::is_convertible_unit_t<UnitTypeLhs, UnitTypeRhs>::value,
|
||||
"Parameters of fmin() function are not compatible units.");
|
||||
return UnitTypeLhs(std::fmin(
|
||||
x(),
|
||||
y.template convert<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// OTHER FUNCTIONS
|
||||
//----------------------------------
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute absolute value
|
||||
* @details Returns the absolute value of x, i.e. |x|.
|
||||
* @param[in] x Value whose absolute value is returned.
|
||||
* @returns The absolute value of x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType fabs(const UnitType x) noexcept {
|
||||
return UnitType(std::fabs(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Compute absolute value
|
||||
* @details Returns the absolute value of x, i.e. |x|.
|
||||
* @param[in] x Value whose absolute value is returned.
|
||||
* @returns The absolute value of x.
|
||||
*/
|
||||
template <class UnitType,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
|
||||
UnitType abs(const UnitType x) noexcept {
|
||||
return UnitType(std::fabs(x()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup UnitMath
|
||||
* @brief Multiply-add
|
||||
* @details Returns x*y+z. The function computes the result without losing
|
||||
* precision in any intermediate result. The resulting unit type is a
|
||||
* compound unit of x* y.
|
||||
* @param[in] x Values to be multiplied.
|
||||
* @param[in] y Values to be multiplied.
|
||||
* @param[in] z Value to be added.
|
||||
* @returns The result of x*y+z
|
||||
*/
|
||||
template <class UnitTypeLhs, class UnitMultiply, class UnitAdd,
|
||||
class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
|
||||
traits::is_unit_t<UnitMultiply>::value &&
|
||||
traits::is_unit_t<UnitAdd>::value>>
|
||||
auto fma(const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept
|
||||
-> decltype(x * y) {
|
||||
using resultType = decltype(x * y);
|
||||
static_assert(
|
||||
traits::is_convertible_unit_t<
|
||||
compound_unit<
|
||||
typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type,
|
||||
typename units::traits::unit_t_traits<UnitMultiply>::unit_type>,
|
||||
typename units::traits::unit_t_traits<UnitAdd>::unit_type>::value,
|
||||
"Unit types are not compatible.");
|
||||
return resultType(std::fma(x(), y(), resultType(z)()));
|
||||
}
|
||||
|
||||
} // namespace math
|
||||
} // namespace units
|
||||
19
wpiutil/src/main/native/include/units/moment_of_inertia.h
Normal file
19
wpiutil/src/main/native/include/units/moment_of_inertia.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/area.h"
|
||||
#include "units/base.h"
|
||||
#include "units/mass.h"
|
||||
|
||||
namespace units {
|
||||
UNIT_ADD(moment_of_inertia, kilogram_square_meter, kilogram_square_meters,
|
||||
kg_sq_m, compound_unit<mass::kilograms, area::square_meters>)
|
||||
|
||||
using namespace moment_of_inertia;
|
||||
} // namespace units
|
||||
54
wpiutil/src/main/native/include/units/power.h
Normal file
54
wpiutil/src/main/native/include/units/power.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::power
|
||||
* @brief namespace for unit types and containers representing power values
|
||||
* @details The SI unit for power is `watts`, and the corresponding `base_unit`
|
||||
* category is `power_unit`.
|
||||
* @anchor powerContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_POWER_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(power, watt, watts, W,
|
||||
unit<std::ratio<1>, units::category::power_unit>)
|
||||
UNIT_ADD(power, horsepower, horsepower, hp, unit<std::ratio<7457, 10>, watts>)
|
||||
UNIT_ADD_DECIBEL(power, watt, dBW)
|
||||
UNIT_ADD_DECIBEL(power, milliwatt, dBm)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(power)
|
||||
#endif
|
||||
|
||||
using namespace power;
|
||||
} // namespace units
|
||||
62
wpiutil/src/main/native/include/units/pressure.h
Normal file
62
wpiutil/src/main/native/include/units/pressure.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/force.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::pressure
|
||||
* @brief namespace for unit types and containers representing pressure values
|
||||
* @details The SI unit for pressure is `pascals`, and the corresponding
|
||||
* `base_unit` category is `pressure_unit`.
|
||||
* @anchor pressureContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_PRESSURE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
pressure, pascal, pascals, Pa,
|
||||
unit<std::ratio<1>, units::category::pressure_unit>)
|
||||
UNIT_ADD(pressure, bar, bars, bar, unit<std::ratio<100>, kilo<pascals>>)
|
||||
UNIT_ADD(pressure, mbar, mbars, mbar, unit<std::ratio<1>, milli<bar>>)
|
||||
UNIT_ADD(pressure, atmosphere, atmospheres, atm,
|
||||
unit<std::ratio<101325>, pascals>)
|
||||
UNIT_ADD(pressure, pounds_per_square_inch, pounds_per_square_inch, psi,
|
||||
compound_unit<force::pounds, inverse<squared<length::inch>>>)
|
||||
UNIT_ADD(pressure, torr, torrs, torr, unit<std::ratio<1, 760>, atmospheres>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(pressure)
|
||||
#endif
|
||||
|
||||
using namespace pressure;
|
||||
} // namespace units
|
||||
71
wpiutil/src/main/native/include/units/radiation.h
Normal file
71
wpiutil/src/main/native/include/units/radiation.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/frequency.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::radiation
|
||||
* @brief namespace for unit types and containers representing radiation values
|
||||
* @details The SI units for radiation are:
|
||||
* - source activity: becquerel
|
||||
* - absorbed dose: gray
|
||||
* - equivalent dose: sievert
|
||||
* @anchor radiationContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_RADIATION_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(radiation, becquerel, becquerels, Bq,
|
||||
unit<std::ratio<1>, units::frequency::hertz>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
radiation, gray, grays, Gy,
|
||||
compound_unit<energy::joules, inverse<mass::kilogram>>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(radiation, sievert, sieverts, Sv,
|
||||
unit<std::ratio<1>, grays>)
|
||||
UNIT_ADD(radiation, curie, curies, Ci, unit<std::ratio<37>, gigabecquerels>)
|
||||
UNIT_ADD(radiation, rutherford, rutherfords, rd,
|
||||
unit<std::ratio<1>, megabecquerels>)
|
||||
UNIT_ADD(radiation, rad, rads, rads, unit<std::ratio<1>, centigrays>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(radioactivity)
|
||||
#endif
|
||||
|
||||
using namespace radiation;
|
||||
} // namespace units
|
||||
59
wpiutil/src/main/native/include/units/solid_angle.h
Normal file
59
wpiutil/src/main/native/include/units/solid_angle.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/angle.h"
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::solid_angle
|
||||
* @brief namespace for unit types and containers representing solid_angle
|
||||
* values
|
||||
* @details The SI unit for solid_angle is `steradians`, and the corresponding
|
||||
* `base_unit` category is `solid_angle_unit`.
|
||||
* @anchor solidAngleContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_SOLID_ANGLE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
solid_angle, steradian, steradians, sr,
|
||||
unit<std::ratio<1>, units::category::solid_angle_unit>)
|
||||
UNIT_ADD(solid_angle, degree_squared, degrees_squared, sq_deg,
|
||||
squared<angle::degrees>)
|
||||
UNIT_ADD(solid_angle, spat, spats, sp,
|
||||
unit<std::ratio<4>, steradians, std::ratio<1>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(solid_angle)
|
||||
#endif
|
||||
|
||||
using namespace solid_angle;
|
||||
} // namespace units
|
||||
52
wpiutil/src/main/native/include/units/substance.h
Normal file
52
wpiutil/src/main/native/include/units/substance.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::substance
|
||||
* @brief namespace for unit types and containers representing substance values
|
||||
* @details The SI unit for substance is `moles`, and the corresponding
|
||||
* `base_unit` category is `substance_unit`.
|
||||
* @anchor substanceContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_SUBSTANCE_UNITS)
|
||||
UNIT_ADD(substance, mole, moles, mol,
|
||||
unit<std::ratio<1>, units::category::substance_unit>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(substance)
|
||||
#endif
|
||||
|
||||
using namespace substance;
|
||||
} // namespace units
|
||||
62
wpiutil/src/main/native/include/units/temperature.h
Normal file
62
wpiutil/src/main/native/include/units/temperature.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
// NOTE: temperature units have special conversion overloads, since they
|
||||
// require translations and aren't a reversible transform.
|
||||
|
||||
/**
|
||||
* @namespace units::temperature
|
||||
* @brief namespace for unit types and containers representing temperature
|
||||
* values
|
||||
* @details The SI unit for temperature is `kelvin`, and the corresponding
|
||||
* `base_unit` category is `temperature_unit`.
|
||||
* @anchor temperatureContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_TEMPERATURE_UNITS)
|
||||
UNIT_ADD(temperature, kelvin, kelvin, K,
|
||||
unit<std::ratio<1>, units::category::temperature_unit>)
|
||||
UNIT_ADD(temperature, celsius, celsius, degC,
|
||||
unit<std::ratio<1>, kelvin, std::ratio<0>, std::ratio<27315, 100>>)
|
||||
UNIT_ADD(temperature, fahrenheit, fahrenheit, degF,
|
||||
unit<std::ratio<5, 9>, celsius, std::ratio<0>, std::ratio<-160, 9>>)
|
||||
UNIT_ADD(temperature, reaumur, reaumur, Re, unit<std::ratio<10, 8>, celsius>)
|
||||
UNIT_ADD(temperature, rankine, rankine, Ra, unit<std::ratio<5, 9>, kelvin>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(temperature)
|
||||
#endif
|
||||
|
||||
using namespace temperature;
|
||||
} // namespace units
|
||||
60
wpiutil/src/main/native/include/units/time.h
Normal file
60
wpiutil/src/main/native/include/units/time.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::time
|
||||
* @brief namespace for unit types and containers representing time values
|
||||
* @details The SI unit for time is `seconds`, and the corresponding `base_unit`
|
||||
* category is `time_unit`.
|
||||
* @anchor timeContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_TIME_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(time, second, seconds, s,
|
||||
unit<std::ratio<1>, units::category::time_unit>)
|
||||
UNIT_ADD(time, minute, minutes, min, unit<std::ratio<60>, seconds>)
|
||||
UNIT_ADD(time, hour, hours, hr, unit<std::ratio<60>, minutes>)
|
||||
UNIT_ADD(time, day, days, d, unit<std::ratio<24>, hours>)
|
||||
UNIT_ADD(time, week, weeks, wk, unit<std::ratio<7>, days>)
|
||||
UNIT_ADD(time, year, years, yr, unit<std::ratio<365>, days>)
|
||||
UNIT_ADD(time, julian_year, julian_years, a_j,
|
||||
unit<std::ratio<31557600>, seconds>)
|
||||
UNIT_ADD(time, gregorian_year, gregorian_years, a_g,
|
||||
unit<std::ratio<31556952>, seconds>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(time)
|
||||
#endif
|
||||
|
||||
using namespace time;
|
||||
} // namespace units
|
||||
63
wpiutil/src/main/native/include/units/torque.h
Normal file
63
wpiutil/src/main/native/include/units/torque.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/energy.h"
|
||||
#include "units/force.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::torque
|
||||
* @brief namespace for unit types and containers representing torque values
|
||||
* @details The SI unit for torque is `newton_meters`, and the corresponding
|
||||
* `base_unit` category is `torque_units`.
|
||||
* @anchor torqueContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_TORQUE_UNITS)
|
||||
UNIT_ADD(torque, newton_meter, newton_meters, Nm,
|
||||
unit<std::ratio<1>, units::energy::joule>)
|
||||
UNIT_ADD(torque, foot_pound, foot_pounds, ftlb,
|
||||
compound_unit<length::foot, force::pounds>)
|
||||
UNIT_ADD(torque, foot_poundal, foot_poundals, ftpdl,
|
||||
compound_unit<length::foot, force::poundal>)
|
||||
UNIT_ADD(torque, inch_pound, inch_pounds, inlb,
|
||||
compound_unit<length::inch, force::pounds>)
|
||||
UNIT_ADD(torque, meter_kilogram, meter_kilograms, mkgf,
|
||||
compound_unit<length::meter, force::kiloponds>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(torque)
|
||||
#endif
|
||||
|
||||
using namespace torque;
|
||||
} // namespace units
|
||||
File diff suppressed because it is too large
Load Diff
62
wpiutil/src/main/native/include/units/velocity.h
Normal file
62
wpiutil/src/main/native/include/units/velocity.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
#include "units/time.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::velocity
|
||||
* @brief namespace for unit types and containers representing velocity values
|
||||
* @details The SI unit for velocity is `meters_per_second`, and the
|
||||
* corresponding `base_unit` category is `velocity_unit`.
|
||||
* @anchor velocityContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_VELOCITY_UNITS)
|
||||
UNIT_ADD(velocity, meters_per_second, meters_per_second, mps,
|
||||
unit<std::ratio<1>, units::category::velocity_unit>)
|
||||
UNIT_ADD(velocity, feet_per_second, feet_per_second, fps,
|
||||
compound_unit<length::feet, inverse<time::seconds>>)
|
||||
UNIT_ADD(velocity, miles_per_hour, miles_per_hour, mph,
|
||||
compound_unit<length::miles, inverse<time::hour>>)
|
||||
UNIT_ADD(velocity, kilometers_per_hour, kilometers_per_hour, kph,
|
||||
compound_unit<length::kilometers, inverse<time::hour>>)
|
||||
UNIT_ADD(velocity, knot, knots, kts,
|
||||
compound_unit<length::nauticalMiles, inverse<time::hour>>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(velocity)
|
||||
#endif
|
||||
|
||||
using namespace velocity;
|
||||
} // namespace units
|
||||
55
wpiutil/src/main/native/include/units/voltage.h
Normal file
55
wpiutil/src/main/native/include/units/voltage.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::voltage
|
||||
* @brief namespace for unit types and containers representing voltage values
|
||||
* @details The SI unit for voltage is `volts`, and the corresponding
|
||||
* `base_unit` category is `voltage_unit`.
|
||||
* @anchor voltageContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_VOLTAGE_UNITS)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(
|
||||
voltage, volt, volts, V, unit<std::ratio<1>, units::category::voltage_unit>)
|
||||
UNIT_ADD(voltage, statvolt, statvolts, statV,
|
||||
unit<std::ratio<1000000, 299792458>, volts>)
|
||||
UNIT_ADD(voltage, abvolt, abvolts, abV, unit<std::ratio<1, 100000000>, volts>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(voltage)
|
||||
#endif
|
||||
|
||||
using namespace voltage;
|
||||
} // namespace units
|
||||
86
wpiutil/src/main/native/include/units/volume.h
Normal file
86
wpiutil/src/main/native/include/units/volume.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
// Copyright (c) 2016 Nic Holthaus
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "units/base.h"
|
||||
#include "units/length.h"
|
||||
|
||||
namespace units {
|
||||
/**
|
||||
* @namespace units::volume
|
||||
* @brief namespace for unit types and containers representing volume values
|
||||
* @details The SI unit for volume is `cubic_meters`, and the corresponding
|
||||
* `base_unit` category is `volume_unit`.
|
||||
* @anchor volumeContainers
|
||||
* @sa See unit_t for more information on unit type containers.
|
||||
*/
|
||||
#if !defined(DISABLE_PREDEFINED_UNITS) || \
|
||||
defined(ENABLE_PREDEFINED_VOLUME_UNITS)
|
||||
UNIT_ADD(volume, cubic_meter, cubic_meters, cu_m,
|
||||
unit<std::ratio<1>, units::category::volume_unit>)
|
||||
UNIT_ADD(volume, cubic_millimeter, cubic_millimeters, cu_mm,
|
||||
cubed<length::millimeter>)
|
||||
UNIT_ADD(volume, cubic_kilometer, cubic_kilometers, cu_km,
|
||||
cubed<length::kilometer>)
|
||||
UNIT_ADD_WITH_METRIC_PREFIXES(volume, liter, liters, L,
|
||||
cubed<deci<length::meter>>)
|
||||
UNIT_ADD(volume, cubic_inch, cubic_inches, cu_in, cubed<length::inches>)
|
||||
UNIT_ADD(volume, cubic_foot, cubic_feet, cu_ft, cubed<length::feet>)
|
||||
UNIT_ADD(volume, cubic_yard, cubic_yards, cu_yd, cubed<length::yards>)
|
||||
UNIT_ADD(volume, cubic_mile, cubic_miles, cu_mi, cubed<length::miles>)
|
||||
UNIT_ADD(volume, gallon, gallons, gal, unit<std::ratio<231>, cubic_inches>)
|
||||
UNIT_ADD(volume, quart, quarts, qt, unit<std::ratio<1, 4>, gallons>)
|
||||
UNIT_ADD(volume, pint, pints, pt, unit<std::ratio<1, 2>, quarts>)
|
||||
UNIT_ADD(volume, cup, cups, c, unit<std::ratio<1, 2>, pints>)
|
||||
UNIT_ADD(volume, fluid_ounce, fluid_ounces, fl_oz, unit<std::ratio<1, 8>, cups>)
|
||||
UNIT_ADD(volume, barrel, barrels, bl, unit<std::ratio<42>, gallons>)
|
||||
UNIT_ADD(volume, bushel, bushels, bu,
|
||||
unit<std::ratio<215042, 100>, cubic_inches>)
|
||||
UNIT_ADD(volume, cord, cords, cord, unit<std::ratio<128>, cubic_feet>)
|
||||
UNIT_ADD(volume, cubic_fathom, cubic_fathoms, cu_fm, cubed<length::fathom>)
|
||||
UNIT_ADD(volume, tablespoon, tablespoons, tbsp,
|
||||
unit<std::ratio<1, 2>, fluid_ounces>)
|
||||
UNIT_ADD(volume, teaspoon, teaspoons, tsp, unit<std::ratio<1, 6>, fluid_ounces>)
|
||||
UNIT_ADD(volume, pinch, pinches, pinch, unit<std::ratio<1, 8>, teaspoons>)
|
||||
UNIT_ADD(volume, dash, dashes, dash, unit<std::ratio<1, 2>, pinches>)
|
||||
UNIT_ADD(volume, drop, drops, drop, unit<std::ratio<1, 360>, fluid_ounces>)
|
||||
UNIT_ADD(volume, fifth, fifths, fifth, unit<std::ratio<1, 5>, gallons>)
|
||||
UNIT_ADD(volume, dram, drams, dr, unit<std::ratio<1, 8>, fluid_ounces>)
|
||||
UNIT_ADD(volume, gill, gills, gi, unit<std::ratio<4>, fluid_ounces>)
|
||||
UNIT_ADD(volume, peck, pecks, pk, unit<std::ratio<1, 4>, bushels>)
|
||||
UNIT_ADD(volume, sack, sacks, sacks, unit<std::ratio<3>, bushels>)
|
||||
UNIT_ADD(volume, shot, shots, shots, unit<std::ratio<3, 2>, fluid_ounces>)
|
||||
UNIT_ADD(volume, strike, strikes, strikes, unit<std::ratio<2>, bushels>)
|
||||
|
||||
UNIT_ADD_CATEGORY_TRAIT(volume)
|
||||
#endif
|
||||
|
||||
using namespace volume;
|
||||
} // namespace units
|
||||
Reference in New Issue
Block a user