소스 검색

operator overload for cross-products.

Rachel Brindle 13 년 전
부모
커밋
bb9f2072cd
2개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      gameplay/src/Vector3.h
  2. 7 0
      gameplay/src/Vector3.inl

+ 10 - 0
gameplay/src/Vector3.h

@@ -404,6 +404,16 @@ public:
      * @return The negation of this vector.
      * @return The negation of this vector.
      */
      */
     inline const Vector3 operator-() const;
     inline const Vector3 operator-() const;
+    
+    /**
+     * Returns the cross product of this vector and the given vector
+     *
+     * Note: this does not modify this vector.
+     *
+     * @param v the vector to cross against
+     * @return the cross product
+     */
+    inline const Vector3 operator*(const Vector3& v) const;
 
 
     /**
     /**
      * Calculates the scalar product of this vector with the given value.
      * Calculates the scalar product of this vector with the given value.

+ 7 - 0
gameplay/src/Vector3.inl

@@ -37,6 +37,13 @@ inline const Vector3 Vector3::operator-() const
     return result;
     return result;
 }
 }
 
 
+inline const Vector3 Vector3::operator*(const Vector3& v) const
+{
+    Vector3 result(*this);
+    result.cross(v);
+    return result;
+}
+
 inline const Vector3 Vector3::operator*(float x) const
 inline const Vector3 Vector3::operator*(float x) const
 {
 {
     Vector3 result(*this);
     Vector3 result(*this);