/** * Initalize the line segment with its two endpoints. * * @api * @param \Nubs\Geometron\Point $a One endpoint of the line segment. * @param \Nubs\Geometron\Point $b One endpoint of the line segment. */ public function __construct(Point $a, Point $b) { if (!$a->isSameSpace($b)) { throw new Exception('The two points must be in the same geometric space'); } $this->_a = $a; $this->_b = $b; }
/** * Verify that a point's center is the same point. * * @test * @uses \Nubs\Geometron\Point::__construct * @uses \Nubs\Geometron\Point::vector * @uses \Nubs\Geometron\Point::terms * @covers ::center */ public function center() { $a = new Point(new Vector([5, 7, 9])); $center = $a->center(); $this->assertSame($a->terms(), $center->terms()); }
/** * Check whether the given point belongs to the same geometric space as this * point. * * @api * @param self $b The point to check. * @return bool True if the points are in the same geometric space and false otherwise. */ public function isSameSpace(self $b) { return $this->vector()->isSameVectorSpace($b->vector()); }