New changes also planed in the math parser, for 2.9.8 :
New functions deg2rad() and rad2deg() converts angles specified in degrees to radians (and vice versa).
New postfix operator ° (UTF8-symbol for degrees) can be added to convert an angle in degrees to radians, as in the expression cos(45°) (eq. to cos(deg2rad(45)) or cos(45*pi/180) ).
Functions rot() and ellipse() now consider that their angle arguments are specified in radians instead of degrees (just like the other trigonometric functions in the math parser).
All this avoids to add a bunch of new functions as cosd(), sind(), ... (as done in R, Matlab, etc.)
This may requires some changes in your scripts anyway (even if I tried to make the change myself).
Personally, I’m ok with the symbol addition. It is just a copy and paste into your gmic file, and you can always find it. I think deg2rad() and rad2deg() is more than enough with regards with degree indicator.
Also, is the ~ taken? Maybe ‘o’ as degree indicator?
What I think right now is that the postfix operator should keep the ° symbol. After all, that is the official degree symbol Anything else will look weird.
Windows users that cannot use it can still use deg2rad() indeed (or *pi/180).
That’s more solutions than we actually need in fact!
rep_hex2img_test:
if narg($1)&&narg($2)
hex2img $1
hex2img $2
hex_col_a={crop(#-2)}
hex_col_b={crop(#-1)}
rm[-2,-1]
fi
c=4
1,500,1,3,"begin(
a=["$hex_col_a"];
print(a);
c=$c;
print(c);
);
1;
"
For multiple numbers to work within a, one would have to use “” wrappers. Would it be possible to allow the math parser to read multi-number variable defined in the gmic interpreter?
No, that’s not possible, because the $-operator in the math parser is intended to be a constant value. Vector-valued items or variables cannot be defined to be constant.
I’ve thought a long time about allowing const vectors to be defined in the math parser, but would introduce some disadvantages that do not compensate for the few advantages it provides.
Late to the party commenting here, but on the whole, a “like”. For tutorial writing purposes, I anticipate using deg2rad() and rad2deg() a good deal more than ° because the two formers clearly spell out their intent, and newcomers are already battling with understanding a script author’s intent. Neither requires special keyboard gyrations to get - for some platforms - a ‘special character’. In truth, I had to teach myself to love °. I get its convenience: I may write degrees everywhere and post-fixed ° makes them everywhere radians. That, and ensuring that every angular-related function now takes radians, is a consistency i enjoy. Nice to see this.
PS - thanks for the patches for my scripts. Much appreciated!
Yep, I will be using the two macros (mackerels ). About the degree symbol, I am curious how you input it on your system? I haven’t used Linux, etc., in a while…
That would be so useful here. But, it’s not. I wish the numberpad were replaced with some useful symbol like currency symbol and degree symbol. I never use the numberpad.
Desktop I use here is MATE with Gentoo Linux; standard US keyboard and en-US locale. No explicit ° key. Any application running on this desktop can accept SHIFT+CNTL+U+<code point> (0167 for degree symbol. More keys than Win 10). However, I mostly work in Emacs and have macros assigned for various non-keyboard characters.