compared with
Current by Denis Portnov
on May 01, 2012 16:01.

(show comment)
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (19)

View Page History
h2. Introduction
<h2>Introduction</h2>

<p>This document describes a request for comments for a Mathematics namespace within Zend Framework. The reason I am writing this RFC is that I believe mathematics will play a bigger role in the near future in web projects. With WebGL coming up and HTML5's canvas element being there already there I am sure that more complex projects and applications will come in the future. These applications will do more calculations than a 'normal' website. Zend Framework could have a Zend\Math namespace which will act as a core for all mathematical concepts.</p>

h2. Math currently used in Zend Framework
<h2>Math currently used in Zend Framework</h2>

<p>At the moment of writing, Zend Framework uses a BigInteger class within the Zend\Crypt namespace. This should be refactored to the Zend\Math namespace in order to improve reusability. Also within the Zend\Locale namespace mathematical functions are often used such as a custom round function, normalize, etc. There even is a special class devoted to doing this (Zend\Locale\Math).</p>

<p>The namespace Zend\XmlRpc contains a wrapper class around Zend\Crypt\Math\BigInteger. I'd like to think that a dependency between Zend\XmlRpc and Zend\Math makes more sense than a dependency between Zend\XmlRpc and Zend\Crypt (unless there actually is done some en/decrypting).</p>

h2. What would Zend\Math contain?
<h2>What would Zend\Math contain?</h2>

<p>As already pointed out the Zend\Math namespace should contain the common used math-related classes in other namespaces. This improves reusability. Of course the options are endless but I'd like to share some first ideas:</p>
* Basic math functions such as normalize, clamping, etc.
* Spline algorithims such as Bezier, Hermite or Catmull-Rom
* Random number generating algorithms where "rand();" is not sufficient enough.
* Vector operations
* Matrix operations
* Quaternion operations
<ul>
<li>Basic math functions such as normalize, clamping, etc.</li>
<li>Spline algorithims such as Bezier, Hermite or Catmull-Rom</li>
<li>Random number generating algorithms where &quot;rand();&quot; is not sufficient enough.</li>
<li>Vector operations</li>
<li>Matrix operations</li>
<li>Quaternion operations</li>
* Latitude/longitude <li>Latitude/longitude related calculations (how often did we need to calculate the distance to...?)</li>
</ul>

h3. Updates

* Zend\Math\BigInteger component is ready (with tests). It provides basic arithmetic operations, base conversion and int/binary conversions. Code is [here|https://github.com/denixport/zf2/tree/feature/math-biginteger/library/Zend/Math/BigInteger/]
<h3>Updates</h3>

* Zend\Math\Rand component is ready. Please see [updated RFC|http://framework.zend.com/wiki/x/HADTAg] and code in [this feature branch|https://github.com/denixport/zf2/tree/feature/rand/library/Zend/Math/Rand]
<ul>
<li>Zend\Math\BigInteger component is ready (with tests). It provides basic arithmetic operations, base conversion and int/binary conversions. Code is <a href="https://github.com/denixport/zf2/tree/feature/math-biginteger/library/Zend/Math/BigInteger/">here</a></li>
</ul>


<ul>
<li>Zend\Math\Rand component is ready. Please see <a href="http://framework.zend.com/wiki/x/HADTAg">updated RFC</a> and code in <a href="https://github.com/denixport/zf2/tree/feature/rand/library/Zend/Math/Rand">this feature branch</a></li>
</ul>