/** * (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)); }
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; }
/** * @param \Maths\PointInterface $a * @return bool */ public function isValidPoint(PointInterface $a) { return (bool) ($a->getOrdinate() == $this->getSlope() * $a->getAbscissa() + $this->getYIntercept()); }