Skip to content

Angular Quantities and Torque Calculations

Try it live on Compiler Explorer

Overview

Angular mechanics requires careful handling of angles, angular positions, and angular-dependent quantities like torque. This example demonstrates using the dedicated ISQ angular system to calculate torque from force, lever arm position, and angle with proper dimensional analysis.

Key Concepts

The ISQ Angular System

The library provides isq_angle, an alternative ISQ system that treats angles as dimensional quantities rather than dimensionless:

  using namespace mp_units;
  using namespace mp_units::si::unit_symbols;
  using mp_units::angular::unit_symbols::deg;
  using mp_units::angular::unit_symbols::rad;

  const quantity lever = isq_angle::position_vector(20 * cm);
  const quantity force = isq_angle::force(500 * N);
  const quantity angle = isq_angle::angular_measure(90. * deg);
  const quantity torque = isq_angle::torque(lever * force * angular::sin(angle) / (1 * isq_angle::cotes_angle));

In this system:

  • isq_angle::position_vector represents a position with angular dependence
  • isq_angle::force represents force with angular considerations
  • isq_angle::angular_measure explicitly represents angles (not dimensionless)
  • isq_angle::torque has dimensions that include angular components

Dimensional Torque Calculation

The torque formula τ = r × F × sin(θ) is implemented with full dimensional checking:

  const quantity torque = isq_angle::torque(lever * force * angular::sin(angle) / (1 * isq_angle::cotes_angle));

The division by cotes_angle normalizes the angular measure to work correctly with the dimensional analysis system, ensuring that the resulting torque has the proper dimensions.

Working with Angles as Quantities

Unlike treating angles as dimensionless (radians as pure numbers), this approach makes angles first-class quantities:

const quantity angle = isq_angle::angular_measure(90. * deg);

This enables:

  • Compile-time checking that angles are used correctly
  • Explicit conversion between angle units (degrees, radians, etc.)
  • Prevention of accidentally treating angles as scalars

Output Formatting

The result is displayed with explicit angular units:

  std::cout << "Applying a perpendicular force of " << force << " to a " << lever << " long lever results in "

Sample Output:

Applying a perpendicular force of 500 N to a 20 cm long lever results in 100 m N/rad of torque.

Why This Matters

  • Dimensional Correctness: Angles are strong quantities, not just numbers — this system enforces that
  • Rotational Mechanics: Essential for robotics, mechanical engineering, aerospace applications
  • Type Safety: Prevents mixing angular and linear quantities inappropriately
  • ISQ Compliance: Follows international standards for quantity systems

Alternative Approach

For simpler cases where angles can be treated as dimensionless, the standard isq system can be used. The isq_angle system is valuable when you need stronger type checking for angular quantities or when working with standards that treat angles dimensionally.

  • Angular velocity and acceleration
  • Moment of inertia
  • Angular momentum
  • Rotational kinetic energy

All of these benefit from treating angles as dimensional quantities rather than pure scalars.

For more details on the theoretical background and design decisions, see the Strong Angular System chapter in the user's guide.