Extension:MathFunctions

What can this extension do?
MathFunctions enhances MediaWiki parser with mathematical functions sin, cos, tan, sqrt and others. This extension also adds ability to convert numbers between numerical bases and ability convert radians to deggress and reverse.

Usage
This extension can be used as any other parser functions extension, for example:  or .

Geo distance
On October 29, 2008 the Geo distance function was added (thanks to Pnelnik). This function calculates distance between two points on the Earth. Result is in kilometres.

It is compatible with the results returned by the geocode function. For points that are south of the equator the northern degrees will be negative and similarly for points that are west of the Greenwich meridian, the eastern degrees will be negative. It uses the following assumptions
 * The earth is a perfect sphere, the fact the earth is slightly flattened at the poles is ignored.
 * The altitude is ignored, the distance reported is the distance along the earth surface at sea level.
 * It is exactly 10,000 km from the equator to either pole, let this be R

Internally the function will convert the angles from degrees to radians, we'll call the angles in radians N1, E1, N2, E2. Then we work out the straight line distance through the earth between the two points: D_through = R * sqrt { (cos(N1)*sin(E1) - cos(N2)*sin(E2))^2 + (cos(N1)*cos(E1) - cos(N2)*cos(E2))^2 + ( sin(N1) - sin(N2))^2 } and the distance along the surface is D_surface = 2 * R * asin ( D_through / [ 2 * R ] )

Download instructions
Just copy the code from code section and paste it to a file, that save to your extensions directory as MathFunctions.php.

Installation
To install this extension, add the following at the end (but before closing delimiter ?>) of your LocalSettings.php: