예제 #1
0
 public function testCatmullRom()
 {
     // simple straight line case (both ends have duplicated control points)
     $c = new CatmullRom1D(0, 0, 10, 10);
     $this->assertEquals(0, $c->calculate(0));
     $this->assertEquals(5, $c->calculate(0.5));
     $this->assertEquals(10, $c->calculate(1));
 }
 function calculateCRSpan($startIndex, $pointsPerSpan = 32)
 {
     $cr_x = new CatmullRom1D($this->controlPoints[$startIndex]->x, $this->controlPoints[$startIndex + 1]->x, $this->controlPoints[$startIndex + 2]->x, $this->controlPoints[$startIndex + 3]->x);
     $cr_y = new CatmullRom1D($this->controlPoints[$startIndex]->y, $this->controlPoints[$startIndex + 1]->y, $this->controlPoints[$startIndex + 2]->y, $this->controlPoints[$startIndex + 3]->y);
     for ($i = 1; $i <= $pointsPerSpan; $i++) {
         $t = $i / $pointsPerSpan;
         $x = $cr_x->calculate($t);
         $y = $cr_y->calculate($t);
         $this->curvePoints->addPoint(new WMPoint($x, $y));
     }
 }