setMatrixV($vector); return $v; } /** * Set vector value * * @param int $m Position to set * @param int|float $value Value to set * * @return void * * @since 1.0.0 */ public function setV(int $m, int | float $value) : void { parent::set($m , 0, $value); } /** * Get vector value * * @param int $m Position to get * * @return int|float * * @since 1.0.0 */ public function getV(int $m) : int | float { return parent::get($m, 0); } /** * Set matrix * * @param array $vector 1-Dimensional array * * @return Vector * * @since 1.0.0 */ public function setMatrixV(array $vector) : self { foreach ($vector as $key => $value) { $this->setV($key, $value); } return $this; } /** * Calculate the cross product * * @param self $vector 3 Vector * * @return Vector * * @since 1.0.0 */ public function cross3(self $vector) : self { $crossArray = [ $this->getV(1) * $vector->getV(2) - $this->getV(2) * $vector->getV(1), $this->getV(2) * $vector->getV(0) - $this->getV(0) * $vector->getV(2), $this->getV(0) * $vector->getV(1) - $this->getV(1) * $vector->getV(0), ]; return self::fromArray($crossArray); } }