PHP code example of poseidon2 / math
1. Go to this page and download the library: Download poseidon2/math library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
poseidon2 / math example snippets
$polarVector = new \Math\Vector\PolarVector();
$length = 10;
$angleRad = 3.14;
$polarVector->setR($length)->getOmega($angleRad);
/**
* return [length, angleInRad {range +- pi}]
*/
$vectorArray180 = $polarVector->getVector(\Math\EnumRange::G180);
/**
* return [length, angleInRad {range: 2 * pi}]
*/
$vectorArray360 = $polarVector->getVector(\Math\EnumRange::G360);
$getClone = false
$polarVector->rotate(2 * pi(), $getClone)
/**
* same as
*/
$polarVector->againstVector($getClone)
$vector1 = (new Math\Vector\PolarVector())->setR(10)->setOmega(pi());
$vector2 = (new Math\Vector\PolarVector())->setR(20)->setOmega( pi() / 2 );
$vectorOperation = new Math\Vector\PolarVectorOperation()
$vector3 = $vectorOperation($vector1, $vector2, Math\Vector\Operator::PLUS, Math\EnumRange::G180);
# Bin
$int = Math\Bin\BinDec::bin2dec('101000101', false, 1);