|
|
William F Pokorny <ano### [at] anonymousorg> wrote:
> Anyhow. In general, I agree with the suggestions in your post! :-)
I had a bit of time to wind down after work, and got sucked back into playing
with pigment function {}} patterns.
There are certain functions that we already have and that can be used in clever
ways (Thanks TOK) such as f_r and select ();
If I don't get to it at some point in the near future, I'd suggest an include
file that allows users to employ these in a somewhat more "code readable"
fashion. By that I mean that f_r should have an alias function declared such as
#declare vector_length = function {f_r (x, y, z)}
and TOK's various select () permutations might be confusing to employ without a
little cheat sheet.
I'm considering writing some "help functions" that store the valid domains of
various functions, such that it's easy to output to the debug stream, use as a
protective wrapper / sanity check for avoiding parse errors, graphing the valid
domains of the functions, and probably an insert-menu cheat sheet would be a
simple but useful idea as well.
Anyway, that was a long-winded lead-in to the fact that I often find myself
needing to use some of the odder trigonometric functions and their inverses, and
the following ought to be in-built functions.
#declare fmod = function (Value, Modulo) {select (Value, 1 - mod (abs (Value),
Modulo), mod (abs (Value), Modulo))} // this gives a mod function that remains
consistant across the origin
// trigonometric functions
#declare csc = function (N) {1/sin(N)}
#declare sec = function (N) {1/cos(N)}
#declare cot = function (N) {1/tan(N)}
// inverse trigonometric functions
#declare acsc = function (N) {asin(1 / N)}
#declare asec = function (N) {acos(1 / N)}
#declare acot = function (N) {atan(1 / N)}
This reminds me to look into hyperbolic and spherical functions as well...
With regard to interesting functions that (barring TOK-level functional coding)
likely can "only" be coded as algorithms in source, or would likely only be
useful if leverage the speed of being a compiled internal "function" (algorithm)
are:
GCD (HCF)
LCM
https://www.geeksforgeeks.org/mathematical-algorithms/mathematical-algorithms-gcd-lcm/
! factorial
Strangely, sgn (N) is not inbuilt.
And I guess until I run into something else, that's it for today's installment.
:)
- BW
Post a reply to this message
|
|