/** * @return PointSet */ public function produce() { $result = new PointSet(); foreach ($this->lowerLeft->forXTimes($this->width) as $x) { foreach ($this->lowerLeft->forYTimes($this->height) as $y) { $point = new Point($x, $y); $value = $this->getValue($point); $result->attach($point, $value); } } return $result; }
/** * @return PointSet */ public function produce() { $result = new PointSet(); foreach ($this->lowerLeft->forXUpTo($this->upperRight) as $x) { foreach ($this->lowerLeft->forYUpTo($this->upperRight) as $y) { $point = new Point($x, $y); $value = $this->getValue($point); $result->attach($point, $value); } } return $result; }
public function test_diff() { $a = new PointSet([new Point(1, 1), new Point(2, 2), new Point(3, 3)]); $b = new PointSet([new Point(3, 1), new Point(2, 2), new Point(1, 3)]); $r = $a->diff($b); static::assertEquals(3, $a->count()); static::assertEquals(3, $b->count()); static::assertEquals(2, $r->count()); static::assertNotSame($r, $a); static::assertNotSame($r, $b); static::assertTrue($r->contains(new Point(1, 1))); static::assertTrue($r->contains(new Point(3, 3))); }
/** * @param PointSet $result * @param Point $point */ private function addPoint(PointSet $result, Point $point) { $value = $this->getValue($point); $result->attach($point, $value); }