Skip to content

Consider adding expression templates support for norm, dot, and cross products on vector quantities #463

@mpusz

Description

@mpusz

We all expect that length * time will not result in speed because we clearly have an error in calculation.

Dot and cross products in vector quantities domain are really similar operations to * and / in the scalar domain. Using a wrong operation by mistake results in a different quantity than expected. Not having support for it makes the library not safe for projects that work on vector quantities.

As the V2 library has now experimental support for vector and tensor quantities as well, it could be a good idea to add the above to improve safety. Also, it would improve ISQ system specification as we will not have to override the quantity character for derived quantities, i.e.:

QUANTITY_SPEC(power, force * velocity, quantity_character::scalar);
QUANTITY_SPEC(moment_of_force, position_vector * force);  // vector
QUANTITY_SPEC(torque, moment_of_force, quantity_character::scalar);
QUANTITY_SPEC(surface_tension, force / length, quantity_character::scalar);  // TODO what is a correct equation here?

The above could be rewritten as:

QUANTITY_SPEC(power, dot(force, velocity));   // or we can assume that `op*` means a dot product
QUANTITY_SPEC(moment_of_force, cross(position_vector, force));
QUANTITY_SPEC(torque, dot(moment_of_force, unit_vector));  // I do not know what a `unit_vector` here should be
QUANTITY_SPEC(surface_tension, norm(force) / length);

Please do share your ideas or comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions