Пример #1
0
 /**
  * Get the [B->D] diagonal as a Segment with a positive direction(s)
  *
  * @return  Segment
  * @throws  \InvalidArgumentException caught on Segment creation
  */
 public function getSecondDiagonal()
 {
     $b = 'b';
     $d = 'd';
     $directions = Maths::getDirectionByPoints($this->getPointB(), $this->getPointD());
     if ($directions[0] == -1) {
         $b = 'd';
         $d = 'b';
     }
     try {
         return $this->getSegment($b, $d);
     } catch (\InvalidArgumentException $e) {
         throw $e;
     }
 }
Пример #2
0
 /**
  * Rearrange a segment to have [A->B] in requested direction
  *
  * @param   int     $direction
  * @return  $this
  */
 public function rearrange($direction = Maths::DIRECTION_POSITIVE)
 {
     $a = $this->getPointA();
     $b = $this->getPointB();
     $directions = Maths::getDirectionByPoints($a, $b);
     if ($directions[0] != $direction) {
         $this->setPointA($b);
         $this->setPointB($a);
     }
     return $this;
 }
Пример #3
0
echo "\n\n";
echo '$point2d->name = "D";' . "\n";
echo 'var_export($point2d);' . "\n";
$point2d->name = 'D';
var_export($point2d);
echo "\n\n";
$point_d1 = new Maths\Point2D(2, 2);
$point_d2 = new Maths\Point2D(3, 4);
$point_d3 = new Maths\Point2D(0, 1);
echo '$point_d1 = new Maths\\Point2D(2,2);' . "\n";
echo '$point_d2 = new Maths\\Point2D(3,4);' . "\n";
echo '$point_d3 = new Maths\\Point2D(0,1);' . "\n";
echo 'echo \\Maths\\Maths::getDirectionByPoints($point_d1, $point_d2))' . "\n";
echo var_export(\Maths\Maths::getDirectionByPoints($point_d1, $point_d2), 1) . "\n";
echo 'echo \\Maths\\Maths::getDirectionByPoints($point_d1, $point_d3))' . "\n";
echo var_export(\Maths\Maths::getDirectionByPoints($point_d1, $point_d3), 1) . "\n";
?>
    </pre>

    <h4>Maths\Point3D</h4>

    <pre class="code" data-language="php">
<?php 
$point3d = new Maths\Point3D(2, 4, 8);
echo '$point3d = new Maths\\Point3D(2,4,8);' . "\n";
echo $point3d . "\n";
echo 'echo $point3d->is1D()' . "\n";
echo var_export($point3d->is1D(), 1) . "\n";
echo 'echo $point3d->is2D()' . "\n";
echo var_export($point3d->is2D(), 1) . "\n";
echo 'echo $point3d->is3D()' . "\n";
Пример #4
0
 /**
  * Get vector's direction
  *
  * @return  array
  */
 public function getDirection()
 {
     return Maths::getDirectionByPoints($this->getPointA(), $this->getPointB());
 }