/** * Triangle constructor. * * @param Point2d $pointA A point * @param Point2d $pointB B point * @param Point2d $pointC C point */ public function __construct(Point2d $pointA, Point2d $pointB, Point2d $pointC) { parent::__construct(); $this->setPointA($pointA); $this->setPointB($pointB); $this->setPointC($pointC); }
/** * Rectangle constructor. * * @param Point2d $pointA A point * @param Point2d $pointB B point * @param Point2d $pointC C point * @param Point2d $pointD D point * @throws Exception */ public function __construct(Point2d $pointA, Point2d $pointB, Point2d $pointC, Point2d $pointD) { parent::__construct(); $test1 = Point2d::getAngle($pointA, $pointD, $pointB); $test2 = Point2d::getAngle($pointB, $pointA, $pointC); $test3 = Point2d::getAngle($pointC, $pointB, $pointD); $test4 = Point2d::getAngle($pointD, $pointC, $pointA); if ($test1 != deg2rad(90) || $test2 != deg2rad(90) || $test3 != deg2rad(90) || $test4 != deg2rad(90)) { throw new Exception('Points must be draw a rectangle!'); } $this->setPointA($pointA); $this->setPointB($pointB); $this->setPointC($pointC); $this->setPointD($pointD); }