Enable trigonometrical functions to #expr
Closed, ResolvedPublic

Description

Author: rene.kijewski

Description:
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


Version: unspecified
Severity: enhancement

bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz13216.
bzimport created this task.Via LegacyMar 1 2008, 10:58 PM
bzimport added a comment.Via ConduitMar 1 2008, 11:15 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.

bzimport added a comment.Via ConduitMar 1 2008, 11:26 PM

rene.kijewski wrote:

changed Expr.php

attachment Expr.php ignored as obsolete

bzimport added a comment.Via ConduitMar 2 2008, 7:57 AM

visi-on wrote:

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

tstarling added a comment.Via ConduitMar 3 2008, 1:52 AM

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

bzimport added a comment.Via ConduitMar 4 2008, 2:41 PM

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.

bzimport added a comment.Via ConduitApr 9 2008, 4:49 PM

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

Raymond added a comment.Via ConduitApr 23 2008, 3:09 PM

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

Add Comment

Column Prototype
This is a very early prototype of a persistent column. It is not expected to work yet, and leaving it open will activate other new features which will break things. Press "\" (backslash) on your keyboard to close it now.