Last modified: 2008-04-23 15:09:56 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 13216 - Enable trigonometrical functions to #expr
Enable trigonometrical functions to #expr
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
All All
: Normal enhancement with 4 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: easy, patch, patch-need-review
Depends on:
  Show dependency treegraph
Reported: 2008-03-01 22:58 UTC by René Kijewski
Modified: 2008-04-23 15:09 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

changed Expr.php (14.15 KB, text/plain)
2008-03-01 23:26 UTC, René Kijewski
Patch against rev32536 (6.10 KB, patch)
2008-04-09 16:49 UTC, René Kijewski

Description René Kijewski 2008-03-01 22:58:37 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)
Comment 1 Robert Leverington 2008-03-01 23:15:24 UTC
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.
Comment 2 René Kijewski 2008-03-01 23:26:50 UTC
Created attachment 4687 [details]
changed Expr.php
Comment 3 visi-on 2008-03-02 07:57:05 UTC
Please add also the functions: abs, trunc, floor and log
Comment 4 Tim Starling 2008-03-03 01:52:05 UTC
Why would you need to do a polar->cartesian transformation in wikitext? 
Comment 5 René Kijewski 2008-03-04 14:41:44 UTC
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.
Comment 6 René Kijewski 2008-04-09 16:49:30 UTC
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.
Comment 7 Raimond Spekking 2008-04-23 15:09:56 UTC
Applied with r33780 with slight modifications (adding two error messages).

Note You need to log in before you can comment on or make changes to this bug.