mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 12:54:25 +02:00
feat(example): experimental_angle
example replaced
This commit is contained in:
@@ -21,8 +21,10 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#include <units/generic/angle.h>
|
#include <units/generic/angle.h>
|
||||||
#include <units/isq/si/energy.h>
|
#include <units/isq/si/force.h>
|
||||||
|
#include <units/isq/si/length.h>
|
||||||
#include <units/isq/si/torque.h>
|
#include <units/isq/si/torque.h>
|
||||||
|
#include <units/math.h>
|
||||||
#include <units/quantity_io.h>
|
#include <units/quantity_io.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -30,15 +32,14 @@ int main()
|
|||||||
{
|
{
|
||||||
using namespace units;
|
using namespace units;
|
||||||
using namespace units::isq;
|
using namespace units::isq;
|
||||||
|
using namespace units::aliases;
|
||||||
using namespace units::aliases::isq::si;
|
using namespace units::aliases::isq::si;
|
||||||
|
|
||||||
const auto torque = N_m_per_rad<>(20.0 / std::numbers::pi);
|
const Length auto lever = cm<>(20);
|
||||||
const auto energy = J<>(20.0);
|
const Force auto force = N<>(500);
|
||||||
|
const Angle auto angle = deg<>(90);
|
||||||
|
const Torque auto torque = lever * force * sin(angle) / cotes_angle<>;
|
||||||
|
|
||||||
Angle auto angle = energy / torque;
|
std::cout << "Applying a perpendicular force of " << force << " to a " << lever << " long lever results in "
|
||||||
|
<< quantity_cast<si::newton_metre_per_radian>(torque) << " of torque.\n";
|
||||||
std::cout << angle << '\n';
|
|
||||||
std::cout << quantity_cast<revolution>(angle) << '\n';
|
|
||||||
std::cout << quantity_cast<degree>(angle) << '\n';
|
|
||||||
std::cout << quantity_cast<gradian>(angle) << '\n';
|
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,10 @@
|
|||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#include <units/generic/angle.h>
|
#include <units/generic/angle.h>
|
||||||
#include <units/isq/si/energy.h>
|
#include <units/isq/si/force.h>
|
||||||
|
#include <units/isq/si/length.h>
|
||||||
#include <units/isq/si/torque.h>
|
#include <units/isq/si/torque.h>
|
||||||
|
#include <units/math.h>
|
||||||
#include <units/quantity_io.h>
|
#include <units/quantity_io.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -32,13 +34,11 @@ int main()
|
|||||||
using namespace units::isq;
|
using namespace units::isq;
|
||||||
using namespace units::isq::si::literals;
|
using namespace units::isq::si::literals;
|
||||||
|
|
||||||
const auto torque = 20.0_q_N_m_per_rad / std::numbers::pi;
|
const Length auto lever = 20_q_cm;
|
||||||
const auto energy = 20.0_q_J;
|
const Force auto force = 500_q_N;
|
||||||
|
const Angle auto angle = 90._q_deg;
|
||||||
|
const Torque auto torque = lever * force * sin(angle) / cotes_angle<>;
|
||||||
|
|
||||||
Angle auto angle = energy / torque;
|
std::cout << "Applying a perpendicular force of " << force << " to a " << lever << " long lever results in "
|
||||||
|
<< quantity_cast<si::newton_metre_per_radian>(torque) << " of torque.\n";
|
||||||
std::cout << angle << '\n';
|
|
||||||
std::cout << quantity_cast<revolution>(angle) << '\n';
|
|
||||||
std::cout << quantity_cast<degree>(angle) << '\n';
|
|
||||||
std::cout << quantity_cast<gradian>(angle) << '\n';
|
|
||||||
}
|
}
|
||||||
|
@@ -20,17 +20,16 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
#include <units/generic/angle.h>
|
||||||
|
|
||||||
UNITS_DIAGNOSTIC_PUSH
|
UNITS_DIAGNOSTIC_PUSH
|
||||||
UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
||||||
#include <units/isq/si/force.h> // 'N' (Newton) shadows a template parameter traditionally used as a size of the array
|
#include <units/isq/si/force.h> // 'N' (Newton) shadows a template parameter traditionally used as a size of the array
|
||||||
UNITS_DIAGNOSTIC_POP
|
UNITS_DIAGNOSTIC_POP
|
||||||
|
|
||||||
#include <units/generic/angle.h>
|
|
||||||
#include <units/isq/si/energy.h>
|
|
||||||
#include <units/isq/si/length.h>
|
#include <units/isq/si/length.h>
|
||||||
#include <units/isq/si/torque.h> // IWYU pragma: keep
|
#include <units/isq/si/torque.h>
|
||||||
|
#include <units/math.h>
|
||||||
#include <units/quantity_io.h>
|
#include <units/quantity_io.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -41,13 +40,11 @@ int main()
|
|||||||
using namespace units::isq::si::references;
|
using namespace units::isq::si::references;
|
||||||
using namespace units::references;
|
using namespace units::references;
|
||||||
|
|
||||||
Torque auto torque = 20.0 / std::numbers::pi * (N * m / rad);
|
const Length auto lever = 20 * cm;
|
||||||
Energy auto energy = 20.0 * J;
|
const Force auto force = 500 * N;
|
||||||
|
const Angle auto angle = 90. * deg;
|
||||||
|
const Torque auto torque = lever * force * sin(angle) / cotes_angle<>;
|
||||||
|
|
||||||
Angle auto angle = energy / torque;
|
std::cout << "Applying a perpendicular force of " << force << " to a " << lever << " long lever results in "
|
||||||
|
<< quantity_cast<si::newton_metre_per_radian>(torque) << " of torque.\n";
|
||||||
std::cout << angle << '\n';
|
|
||||||
std::cout << quantity_cast<revolution>(angle) << '\n';
|
|
||||||
std::cout << quantity_cast<degree>(angle) << '\n';
|
|
||||||
std::cout << quantity_cast<gradian>(angle) << '\n';
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user