Enable trigonometrical functions to #expr
Closed, ResolvedPublic


Author: rene.kijewski

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)

Version: unspecified
Severity: enhancement


bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz13216.
bzimport created this task.Mar 1 2008, 10:58 PM

robert wrote:

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.

rene.kijewski wrote:

changed Expr.php

attachment Expr.php ignored as obsolete

visi-on wrote:

Please add also the functions: abs, trunc, floor and log

Why would you need to do a polar->cartesian transformation in wikitext?

rene.kijewski wrote:

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.

rene.kijewski wrote:

Patch against rev32536

This patch implements sin, cos, tan, asin, acos, atan, exp, ln, abs, floor, trunc, ceil, ^, and the constants pi and e.

Attached: Expr.diff

Applied with r33780 with slight modifications (adding two error messages).

Add Comment