at-import / Sassy-math

Complex math functions for Sass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Naming arguments and categorizing functions

opened this issue · comments

In the readme.md and in the sassy-math.rb files, the inverse trigonometric functions, the hyperbolic functions and their inverses take in an argument called $radians or rad. That's a bit misleading.

The inverse trigonometric functions actually take in a number value (restricted to the interval [-1, 1] in the case of sin and cos) and output an angle value in radians. It's precisely the inverse of the direct trigonometric functions, which take in an angle value in radians and return a number (which is a number between -1 and 1 for sin and cos).

The hyperbolic functions are just that, hyperbolic functions. They're not trigonometric functions and they don't fall under trigonometry, but under hyperbolic geometry. Their name is just an analogy. Just like when plotting the points (sin(a), cos(a)), the result is the unit circle (which is why the trigonometric functions are also called circular functions), when plotting the points (sinh(a), cosh(a)), the result is the unit hyperbola.

Calling the argument for such a function $radians or rad doesn't make much sense, since the radian is a unit of angular measure. Both the hyperbolic functions and their inverses take in a number value and return a number value as well (with the domain restrictions corresponding to each).

Thanks for your input.

The reason it's called rad is because we were following the convention of the Ruby code in which the input is x (expressed in radians), so in aiming to make that definition easier to grok and standard across all like functions (as all likewise, both the trig and hyper functions in Ruby are x (expressed in radians)) it may have been "dumbed down" a little too much. What would you suggest we call the input? Especially because the Ruby functions themselves don't seem to enforce the restricted interval?

As for the title of that section, you're right, that's misleading. I will divide them into their own sections.

I'm not really sure about the name, I'd probably go with something simple like x or a or even value or val. Specifying in the readme and in the Ruby code comments the kind of input and output values and the domains to which they should belong would perhaps help understanding what the function does even better?

asin($x) - Returns the arc sine (in radians) of a number $x. The input $x is constrained to the interval [-1,1] and the returned angle is in the range -π/2 through π/2.
acos($x) - Returns the arc cosine (in radians) of a number $x. The input $x is constrained to the interval [-1,1] and the returned angle is in the range 0 through π.
atan($x) - Returns the arc tangent (in radians) of a number $x. The returned angle is in the range -π/2 through π/2.

sinh($x) - Returns the hyperbolic sine of a number $x.
cosh($x) - Returns the hyperbolic cosine of a number $x. The returned value is in the range [1, +∞].
tanh($x) - Returns the hyperbolic tangent of a number $x. The returned value is in the range [-1, 1].

asinh($x) - Returns the hyperbolic arc sine of a number $x.
acosh($x) - Returns the hyperbolic arc cosine of a number $x. The input $x is constrained to the range [1, +∞].
atanh($x) - Returns the hyperbolic arc tangent of a number $x. The input $x is constrained to the range [-1, 1].

Something like the above, perhaps?