function test2DVector() { $this->assertTrue(Math_VectorOp::isVector2($this->y) && $this->y->isValid()); }
/** * Angle between vectors, using the equation: v . w = |v| |w| cos(theta) * * @access public * @param object Math_Vector2 or MathVector3 (or subclass) $v1 * @param object Math_Vector2 or MathVector3 (or subclass) $v2 * @return mixed the angle between vectors (float, in radians) on success, a PEAR_Error object otherwise * * @see isVector2() * @see isVector3() * @see dotProduct() */ function angleBetween($v1, $v2) { if (Math_VectorOp::isVector2($v1) && Math_VectorOp::isVector2($v2) || Math_VectorOp::isVector3($v1) && Math_VectorOp::isVector3($v2)) { $v1->normalize(); $v2->normalize(); return acos(Math_VectorOp::dotProduct($v1, $v2)); } else { return PEAR::raiseError("Vectors must be both of the same type"); } }
/** * Angle between vectors, using the equation: v . w = |v| |w| cos(theta) * * @param object Math_Vector2 or MathVector3 (or subclass) $v1 * @param object Math_Vector2 or MathVector3 (or subclass) $v2 * @return mixed the angle between vectors (float, in radians) on success * @throws InvalidArgumentException * * @see isVector2() * @see isVector3() * @see dotProduct() */ public static function angleBetween($v1, $v2) { if (Math_VectorOp::isVector2($v1) && Math_VectorOp::isVector2($v2) || Math_VectorOp::isVector3($v1) && Math_VectorOp::isVector3($v2)) { $v1->normalize(); $v2->normalize(); return acos(Math_VectorOp::dotProduct($v1, $v2)); } throw new InvalidArgumentException("Vectors must be both of the same type"); }