-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Most elegant way to convert a length ratio to radians? #684
Comments
Anyway, I just recently made a lengthy comment on an issue for that library. It's directly relevant here, so check it out for some good background info. The short of it in your case is you want to use the fully general equation, Of course, in practice when it comes to the code, you would simply multiply by using mp_units::si::unit_symbols::rad;
quantity DisplacementAngle = Displacement / Distance * rad; |
Hi @etsach 😃
This is actually not the case both for quantities and units:
We need to do the same if we want to be compliant. Based on the above you can calculate angle as either: quantity displacement = 0.1 * mm;
quantity distance = 1 * cm;
quantity<rad> angle = displacement / distance; or quantity displacement = isq::arc_length(0.1 * mm);
quantity distance = isq::radius(1 * cm);
quantity<isq::angular_measure[rad]> angle = displacement / distance; depending if you want to use typed or simple quantities. Said that, we also have experimental strong-angular systems. You can try those if you prefer to treat angle as a strong quantity. |
I'm working on a project, where we often have to compute angles or solid angles from lengths or area and distances.
So we would need to write code like:
radian_t DisplacementAngle = Displacement / Distance;
We are dealing with small angles, think about dα = dL / R
I know that angles were introduced as a strongly typed unit with good reasons, so I will not debate over this here.
But is there a possible nice syntax to write this? Currently I would do this kind of ugly code:
radian_t DisplacementAngle = radian_t((Displacement / Distance).value());
I nothing is available built-in, I would maybe suggest adding this as a trigonometry function, as we are more or less looking for an operation similar to arcsin, except it's linear. We could for instance name it "arcangle" (random name, maybe not the best):
radian_t DisplacementAngle = math::arcangle( Displacement / Distance );
So in short : is there a nice way to write this already? What about introducing this as a function along trig functions? It feels weird that computing the arcsine angle has a nice syntax, but not a dumb arc angle calculation.
The text was updated successfully, but these errors were encountered: