Last modified: 2008-04-23 15:09:56 UTC
There are several cases, when trigonometrical functions like sine or cosine could be usefull. I experienced this issue as I missed a proper functionality to calculate the (co)sine to do a polar projection. It would be nice if expressions like {{#expr:sin (pi*1.5)}} would be working without workarounds like [[mw:Extension:MathStatFunctions]] or Taylor polynoms. I propose a patch enabling (unary) sin, cos, tan, asin, acos, atan, exp and ln, (binary) ^, and pi as a constant. (Lacking a proper diff tool I used de.wp to do the diff) http://de.wikipedia.org/w/index.php?title=Benutzer%3ARevolus%2FExpr.php&diff=43186472&oldid=43185892
Could you just post the file you made because a wiki diff is very unusable as it converts tabs to 4 spaces making troubles when applying the patch; if you just post the file someone can then generate the unified diff. Thanks.
Created attachment 4687 [details] changed Expr.php
Please add also the functions: abs, trunc, floor and log Thanks
Why would you need to do a polar->cartesian transformation in wikitext?
It's not needed in wikitext, but in geo location templates. Take Russia for an example: it's very long from east to west and very northern. So if you take the normal cartesian map, it looks strange, stretched. Almost every Wikipedia uses geo locating, so almost every Wikipedia could be needing it. The functions abs, trunc, floor and log are maybe even more important. By now you have to do everything with cases and polynoms. I change would make #expr some more intuitive and I think it could relieve are parser from some parsings and recursions as well, as you would not need templates to do this anymore.
Created attachment 4797 [details] Patch against rev32536 This patch implements sin, cos, tan, asin, acos, atan, exp, ln, abs, floor, trunc, ceil, ^, and the constants pi and e.
Applied with r33780 with slight modifications (adding two error messages).