trigonometric functions have confusing unit behavior
xeniarose opened this issue · comments
The following in eval.rs clones the input units for all trig functions
rink-rs/core/src/runtime/eval.rs
Lines 289 to 348 in 4a492c6
this results in some confusing behavior when running trig functions with units
> sin(10 deg)
approx. 173.6481 milliradian (angle)
> atan2(5 ft, 2 ft)
approx. 1.190289 meter (length)
i think that the following behavior would make more sense:
sin
,cos
, andtan
should require either dimensionless or angle units as input, and provide a dimensionless outputasin
,acos
,atan
, should require dimensionless input and provide angle outputatan2
should provide angle output, and retain its current check for the dimensionality of the two inputs being the same
if you think input unit constraints would be too much, implementing just the output unit changes would also be fine. i can make a PR for this if these changes are wanted
Sorry it took so long to get around to this. I agree, this is a much better way to handle the units on these functions.