Lines Matching full:point
52 foreach ($this as $point) {
53 $points[] = $point->toArray();
59 public function newPoint(array $coordinates): Point
62 … throw new \LogicException("(" . implode(',', $coordinates) . ") is not a point of this space");
65 return new Point($this, $coordinates);
68 public function addPoint(array $coordinates, $data = null): Point
70 $this->attach($point = $this->newPoint($coordinates), $data);
72 return $point;
75 public function attach($point, $data = null): void argument
77 if (!$point instanceof Point) {
81 parent::attach($point, $data);
98 foreach ($this as $point) {
100 if ($min[$n] === null || $min[$n] > $point[$n]) {
101 $min[$n] = $point[$n];
104 if ($max[$n] === null || $max[$n] < $point[$n]) {
105 $max[$n] = $point[$n];
113 public function getRandomPoint(Point $min, Point $max): Point
115 $point = $this->newPoint(array_fill(0, $this->dimention, null));
119 $point[$n] = $rng($min[$n], $max[$n]);
122 return $point;
181 foreach ($this as $point) {
182 $distance = $point->getDistanceWith($point->getClosest($clusters), false);
222 // initialize N clusters with a random point within space boundaries
239 foreach ($cluster as $point) {
241 $closest = $point->getClosest($clusters);
243 // move the point from its old cluster to its closest
253 $attach[$closest]->attach($point);
254 $detach[$cluster]->attach($point);