/** * Construct rotation matrix from rotation (in degrees) and optional * center point. * * @param int $rotation * @param ezcGraphCoordinate $center * @return ezcGraphTransformation */ public function __construct($rotation = 0, ezcGraphCoordinate $center = null) { $this->rotation = (double) $rotation; if ($center === null) { $this->center = new ezcGraphCoordinate(0, 0); $clockwiseRotation = deg2rad($rotation); $rotationMatrixArray = array(array(cos($clockwiseRotation), -sin($clockwiseRotation), 0), array(sin($clockwiseRotation), cos($clockwiseRotation), 0), array(0, 0, 1)); return parent::__construct($rotationMatrixArray); } parent::__construct(); $this->center = $center; $this->multiply(new ezcGraphTranslation($center->x, $center->y)); $this->multiply(new ezcGraphRotation($rotation)); $this->multiply(new ezcGraphTranslation(-$center->x, -$center->y)); }
/** * Transform vector using transformation matrix * * @param ezcGraphTransformation $transformation * @return ezcGraphVector */ public function transform(ezcGraphTransformation $transformation) { $result = $transformation->transformCoordinate($this); $this->x = $result->x; $this->y = $result->y; return $this; }
/** * Constructor * * @param float $x * @param float $y * @return void * @ignore */ public function __construct($x = 0.0, $y = 0.0) { parent::__construct(array(array(1, 0, $x), array(0, 1, $y), array(0, 0, 1))); }