Beispiel #1
0
 public function drawPoint(PointInterface $point, array $options = array())
 {
     if (array_key_exists('x', $options)) {
         $x = $options['x'];
         unset($options['x']);
     } else {
         $x = $point->getAbscissa();
     }
     if (array_key_exists('y', $options)) {
         $y = $options['y'];
         unset($options['y']);
     } else {
         $y = $point->getOrdinate();
     }
     if (array_key_exists('prefix', $options)) {
         $p = $options['prefix'];
         unset($options['prefix']);
     } else {
         $p = 'p';
     }
     $data = json_encode($options, JSON_NUMERIC_CHECK);
     $name = $p . count($this->_points);
     $this->addOutput("var {$name} = {$this->_brd}.create('point', [{$x},{$y}], {$data});");
     $this->addPoint($name, $point, $options);
     return $name;
 }
Beispiel #2
0
 /**
  * @param   \Maths\PointInterface   $a
  * @return  bool
  */
 public function isValidPoint(PointInterface $a)
 {
     return (bool) ($a->getOrdinate() == $this->getSlope() * $a->getAbscissa() + $this->getYIntercept());
 }
Beispiel #3
0
 /**
  * (x - Ox)^2 + (y - Oy)^2 = r^2
  *
  * @param   \Maths\PointInterface   $a
  * @return  bool
  */
 public function isValidPoint(PointInterface $a)
 {
     $o = $this->getPointO();
     return (bool) (pow($a->getAbscissa() - $o->getAbscissa(), 2) + pow($a->getOrdinate() - $o->getOrdinate(), 2) == pow($this->getRadius(), 2));
 }
Beispiel #4
0
 /**
  * Test if two points are in the same space type
  *
  * @param   \Maths\PointInterface $point1
  * @param   \Maths\PointInterface $point2
  * @return  bool
  */
 public static function areSameSpace(PointInterface $point1, PointInterface $point2)
 {
     return (bool) ($point1->is1D() && $point2->is1d() || $point1->is2D() && $point2->is2d() || $point1->is3D() && $point2->is3d());
 }