Пример #1
0
 /**
  * @param float $x
  *
  * @return float|null
  */
 public function evaluate($x)
 {
     $nowPoint = new Point($x, 0);
     $containingLine = null;
     foreach ($this->path->getLineIterator() as $line) {
         if ($nowPoint->betweenX($line->getStartPoint(), $line->getEndPoint())) {
             $containingLine = $line;
             break;
         }
     }
     if (null === $containingLine) {
         if (false === $this->extrapolate) {
             return null;
         }
         if ($this->path->firstPoint()->getX() > $x) {
             $containingLine = $this->path->firstLine();
         } else {
             $containingLine = $this->path->lastLine();
         }
     }
     return $containingLine->getLinearFunction()->evaluate($x);
 }
Пример #2
0
 /**
  * @param Path $path
  */
 public function __construct(Path $path)
 {
     $this->points = $path->getPoints();
     $this->index = 0;
 }