| @@ 92-94 (lines=3) @@ | ||
| 89 | $centroid = $this->space->newPoint(array_fill(0, $this->dimention, 0)); |
|
| 90 | ||
| 91 | foreach ($this->points as $point) { |
|
| 92 | for ($n=0; $n<$this->dimention; $n++) { |
|
| 93 | $centroid->coordinates[$n] += $point->coordinates[$n]; |
|
| 94 | } |
|
| 95 | } |
|
| 96 | ||
| 97 | for ($n=0; $n<$this->dimention; $n++) { |
|
| @@ 97-99 (lines=3) @@ | ||
| 94 | } |
|
| 95 | } |
|
| 96 | ||
| 97 | for ($n=0; $n<$this->dimention; $n++) { |
|
| 98 | $this->coordinates[$n] = $centroid->coordinates[$n] / $count; |
|
| 99 | } |
|
| 100 | } |
|
| 101 | ||
| 102 | public function getIterator(): \Iterator |
|