Exemplo n.º 1
0
 /**
  * Write a circle like `[(Ax,Ay),(Bx,By),(Cx,Cy)]`
  *
  * @return  string
  */
 public function __toString()
 {
     return Maths::polygonToString($this->is3D() ? array($this->getPointA()->x, $this->getPointA()->y, $this->getPointA()->z) : array($this->getPointA()->x, $this->getPointA()->y), $this->is3D() ? array($this->getPointB()->x, $this->getPointB()->y, $this->getPointB()->z) : array($this->getPointB()->x, $this->getPointB()->y), $this->is3D() ? array($this->getPointC()->x, $this->getPointC()->y, $this->getPointC()->z) : array($this->getPointC()->x, $this->getPointC()->y));
 }
Exemplo n.º 2
0
 /**
  * Write a 2D point as `( x , y )`
  *
  * @return  string
  */
 public function __toString()
 {
     return Maths::coordinatesToString(array($this->getAbscissa(), $this->getOrdinate()));
 }
Exemplo n.º 3
0
 /**
  * Test if the quadrilateral is a parallelogram
  *
  * @return  bool
  */
 public function isParallelogram()
 {
     $centerdiag1 = $this->getFirstDiagonal();
     $centerdiag2 = $this->getSecondDiagonal();
     return (bool) Maths::areSamePoint($centerdiag1->getCenter(), $centerdiag2->getCenter());
 }
Exemplo n.º 4
0
 /**
  * Write a circle like `[circ. O(x,y),r=..]`
  *
  * @return  string
  */
 public function __toString()
 {
     return '[circ. O' . Maths::coordinatesToString(array($this->getPointO()->getAbscissa(), $this->getPointO()->getOrdinate())) . ',r=' . $this->getRadius() . ']';
 }
Exemplo n.º 5
0
echo $segment1->getLength() . "\n";
$segment1->getPointA()->x = -2;
echo $segment1 . "\n";
echo 'echo $segment1->length' . "\n";
echo $segment1->length . "\n";
$seg_para_a = new \Maths\Geometry\Point(1, 2);
$seg_para_b = new \Maths\Geometry\Point(1, 4);
$seg_para_1 = new \Maths\Geometry\Segment($seg_para_a, $seg_para_b);
$seg_para_c = new \Maths\Geometry\Point(3, -1);
$seg_para_d = new \Maths\Geometry\Point(3, 2);
$seg_para_2 = new \Maths\Geometry\Segment($seg_para_c, $seg_para_d);
var_export(\Maths\Maths::areParallels($seg_para_1, $seg_para_2));
$seg_para_e = new \Maths\Geometry\Point(1, -1);
$seg_para_f = new \Maths\Geometry\Point(3, 2);
$seg_para_3 = new \Maths\Geometry\Segment($seg_para_e, $seg_para_f);
var_export(\Maths\Maths::areParallels($seg_para_1, $seg_para_3));
?>
    </pre>

    <h3 id="quadri">Quadrilaterals</h3>

    <h4>Maths\Geometry\Quadrilateral</h4>

    <pre class="code" data-language="php">
<?php 
echo '$rec_pointA = new \\Maths\\Geometry\\Point(1,2);' . "\n";
echo '$rec_pointB = new \\Maths\\Geometry\\Point(4,2);' . "\n";
echo '$rec_pointC = new \\Maths\\Geometry\\Point(4,4);' . "\n";
echo '$rec_pointD = new \\Maths\\Geometry\\Point(1,4);' . "\n";
$rec_pointA = new \Maths\Geometry\Point(1, 2);
$rec_pointB = new \Maths\Geometry\Point(4, 2);
Exemplo n.º 6
0
 /**
  * Write a 3D point as `( x , y , z )`
  *
  * @return  string
  */
 public function __toString()
 {
     return Maths::coordinatesToString($this->is3D() ? array($this->getAbscissa(), $this->getOrdinate(), $this->getApplicate()) : ($this->is2D() ? array($this->getAbscissa(), $this->getOrdinate()) : array($this->getAbscissa())));
 }
Exemplo n.º 7
0
$seg_para_a = new \Maths\Geometry\Point(-1, 2);
$seg_para_b = new \Maths\Geometry\Point(1, 4);
$seg_para_1 = new \Maths\Geometry\Segment($seg_para_a, $seg_para_b);
$jxg->drawSegment($seg_para_1);
$seg_para_c = new \Maths\Geometry\Point(-2.5, 2.5);
$seg_para_d = new \Maths\Geometry\Point(2, 7);
$seg_para_2 = new \Maths\Geometry\Segment($seg_para_c, $seg_para_d);
$jxg->drawSegment($seg_para_2);
$seg_para_e = new \Maths\Geometry\Point(1, -1);
$seg_para_f = new \Maths\Geometry\Point(3, 2);
$seg_para_3 = new \Maths\Geometry\Segment($seg_para_e, $seg_para_f);
$jxg->drawSegment($seg_para_3);
$seg_para_1->rearrange();
$seg_para_2->rearrange();
$abs = array($seg_para_1->getPointA()->getAbscissa(), $seg_para_1->getPointB()->getAbscissa(), $seg_para_2->getPointA()->getAbscissa(), $seg_para_2->getPointB()->getAbscissa());
$ords = array($seg_para_1->getPointA()->getOrdinate(), $seg_para_1->getPointB()->getOrdinate(), $seg_para_2->getPointA()->getOrdinate(), $seg_para_2->getPointB()->getOrdinate());
$e = new \Maths\Geometry\Point(max($abs) + abs(min($abs)) - 2, max($ords) + abs(min($ords)) - 6);
$jxg->drawPoint($e, array('color' => '#00ff00'));
$segAE = new \Maths\Geometry\Segment($seg_para_1->getPointA(), $e);
$segBE = new \Maths\Geometry\Segment($seg_para_1->getPointB(), $e);
$intersectCE = \Maths\Maths::getLinesIntersection($segAE, $seg_para_2);
$segCE = new \Maths\Geometry\Segment($intersectCE, $e);
$intersectDE = \Maths\Maths::getLinesIntersection($segBE, $seg_para_2);
$segDE = new \Maths\Geometry\Segment($intersectDE, $e);
$jxg->drawSegment($segAE, array('color' => '#00ff00'));
$jxg->drawSegment($segBE, array('color' => '#00ff00'));
/*
$ok = \Maths\Maths::areParallels($seg_para_1, $seg_para_2);
$ok = \Maths\Maths::areParallels($seg_para_1, $seg_para_3);
*/
echo $jxg;
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 /**
  * Test if a vector is null : [~0] = [A==B]
  *
  * @return  bool
  */
 public function isNull()
 {
     return (bool) Maths::areSamePoint($this->getPointA(), $this->getPointB());
 }