impl. helper functions for easier use

This commit is contained in:
Dennis Eichhorn 2020-05-04 22:40:35 +02:00
parent 3026fec00c
commit 89e645a0cd
2 changed files with 34 additions and 0 deletions

View File

@ -79,6 +79,23 @@ class Matrix implements \ArrayAccess, \Iterator
}
}
/**
* Create matrix from array
*
* @param array $matrix Matrix array
*
* @return self
*
* @since 1.0.0
*/
public static function fromArray(array $matrix) : self
{
$m = new self();
$m->setMatrix($matrix);
return $m;
}
/**
* Set value.
*

View File

@ -24,6 +24,23 @@ namespace phpOMS\Math\Matrix;
*/
final class Vector extends Matrix
{
/**
* Create vector from array
*
* @param array $vector Matrix array
*
* @return self
*
* @since 1.0.0
*/
public static function fromArray(array $vector) : Vector
{
$v = new self();
$v->setMatrixV($vector);
return $v;
}
/**
* Set vector value
*