function __construct($kwargs) { if (array_key_exists('dest', $kwargs)) { $dest = $kwargs['dest']; $this->_x = $dest->getX(); $this->_y = $dest->getY(); $this->_z = $dest->getZ(); $this->_w = $dest->getW(); } else { echo "Vector: missing dest key in constructor\n"; exit(-1); } if (array_key_exists('orig', $kwargs)) { $orig = $kwargs['orig']; $this->_x -= $orig->getX(); $this->_y -= $orig->getY(); $this->_z -= $orig->getZ(); $this->_w -= $orig->getW(); } else { $orig = new Vertex(array('x' => 0, 'y' => 0, 'z' => 0, 'w' => 1)); $this->_w -= $orig->getW(); } if (self::$verbose === TRUE) { printf("Vector( x:%.02f, y:%.02f, z:%.02f, w:%.02f ) constructed\n", $this->_x, $this->_y, $this->_z, $this->_w); } }
public function transformVertex(Vertex $vtx) { $tmp_array = array(); $tmp_array[0][0] = $vtx->getX(); $tmp_array[1][0] = $vtx->getY(); $tmp_array[2][0] = $vtx->getZ(); $tmp_array[3][0] = $vtx->getW(); return new Vertex(array('x' => $this->_mult_line_row($tmp_array, 0, 0), 'y' => $this->_mult_line_row($tmp_array, 1, 0), 'z' => $this->_mult_line_row($tmp_array, 2, 0), 'color' => $vtx->getColor())); }
private function _setVectorFromVertex(Vertex $orig, Vertex $dest) { $this->_x = $dest->getX() / $dest->getW() - $orig->getX() / $orig->getW(); $this->_y = $dest->getY() / $dest->getW() - $orig->getY() / $orig->getW(); $this->_z = $dest->getZ() / $dest->getW() - $orig->getZ() / $orig->getW(); }