Author: Kore Nordmann Date: 2007-01-31 11:19:05 +0100 (Wed, 31 Jan 2007) New Revision: 4601
Log: - Renamed rotation methods - Added tests for vector rotation Modified: trunk/Graph/src/math/vector.php trunk/Graph/tests/vector_test.php Modified: trunk/Graph/src/math/vector.php =================================================================== --- trunk/Graph/src/math/vector.php 2007-01-31 10:12:37 UTC (rev 4600) +++ trunk/Graph/src/math/vector.php 2007-01-31 10:19:05 UTC (rev 4601) @@ -21,11 +21,11 @@ * * @return void */ - public function toLeft() + public function rotateCounterClockwise() { $tmp = $this->x; - $this->x = -$this->y; - $this->y = $tmp; + $this->x = $this->y; + $this->y = -$tmp; return $this; } @@ -35,11 +35,11 @@ * * @return void */ - public function toRight() + public function rotateClockwise() { $tmp = $this->x; - $this->x = $this->y; - $this->y = -$tmp; + $this->x = -$this->y; + $this->y = $tmp; return $this; } Modified: trunk/Graph/tests/vector_test.php =================================================================== --- trunk/Graph/tests/vector_test.php 2007-01-31 10:12:37 UTC (rev 4600) +++ trunk/Graph/tests/vector_test.php 2007-01-31 10:19:05 UTC (rev 4601) @@ -106,6 +106,40 @@ ); } + public function testVectorRotateClockwise() + { + $vector = new ezcGraphVector( 1, 2 ); + $result = $vector->rotateClockwise(); + + $this->assertEquals( + $result, + new ezcGraphVector( -2, 1 ) + ); + + $this->assertEquals( + $result, + $vector, + 'Result should be the vector itself' + ); + } + + public function testVectorRotateCounterClockwise() + { + $vector = new ezcGraphVector( 1, 2 ); + $result = $vector->rotateCounterClockwise(); + + $this->assertEquals( + $result, + new ezcGraphVector( 2, -1 ) + ); + + $this->assertEquals( + $result, + $vector, + 'Result should be the vector itself' + ); + } + public function testVectorMultiplyCoordinate() { $vector = new ezcGraphVector( 1, 2 ); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components