コード例 #1
0
 /**
  * get() is an alias of point()
  */
 public function testSetGet()
 {
     $point = new pointObj();
     $point->setXY(5, 5);
     $this->assertEquals(0, $this->line->set(1, $point));
     $this->assertInstanceOf('pointObj', $replacedPoint = $this->line->get(1));
     $this->assertEquals(5, $replacedPoint->x);
 }
コード例 #2
0
 public function testDistanceToLine()
 {
     $startLine = new pointObj();
     $startLine->setXY(11, 15);
     $endLine = new pointObj();
     $endLine->setXY(43, 67);
     $this->assertEquals(1.0, $this->point->distanceToLine($startLine, $endLine));
     $startLine->setXY(10, 15);
     $this->assertEquals(0, $this->point->distanceToLine($startLine, $endLine));
 }
コード例 #3
0
 public function testdistanceToPoint()
 {
     $point = new pointObj();
     $point->setXY(5, 8);
     $line = new lineObj();
     $line->addXY(0, 0);
     $line->addXY(6, 8);
     $this->assertTrue(is_nan($this->shape->distanceToPoint($point)));
     $this->shape->add($line);
     $this->assertEquals(1.0, $this->shape->distanceToPoint($point));
 }