Explorar o código

operator overload for cross-products.

Rachel Brindle %!s(int64=13) %!d(string=hai) anos
pai
achega
bb9f2072cd
Modificáronse 2 ficheiros con 17 adicións e 0 borrados
  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.
      */
     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.

+ 7 - 0
gameplay/src/Vector3.inl

@@ -37,6 +37,13 @@ inline const Vector3 Vector3::operator-() const
     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
 {
     Vector3 result(*this);