--- trunk/OOPSE-4/src/math/Vector3.hpp 2004/10/17 01:19:11 1586 +++ trunk/OOPSE-4/src/math/Vector3.hpp 2004/10/18 16:29:53 1590 @@ -39,93 +39,91 @@ namespace oopse { #include "Vector.hpp" namespace oopse { + + /** + * @class Vector3 Vector3.hpp "math/Vector3.hpp" + * @brief + */ + + template + class Vector3 : public Vector{ + public: + Vector3() : Vector(){} + + /** Constructs and initializes a Vector3 from x, y, z coordinates */ + inline Vector3( double x, double y, double z) { + data_[0] = x; + data_[1] = y; + data_[2] = z; + } + + inline Vector3(const Vector& v) : Vector(v) {} + + inline Vector3& operator = (const Vector& v) { + if (this == &v) { return *this; } + Vector::operator=(v); + return *this; + } + /** - * @class Vector3 Vector3.hpp "math/Vector3.hpp" - * @brief + * Retunrs reference of the first element of Vector3. + * @return reference of the first element of Vector3 */ + inline Real& x() { return data_[0];} - template - class Vector3 : public Vector{ - public: - - Vector3() : Vector(){} - - /** Constructs and initializes a Vector3 from x, y, z coordinates */ - inline Vector3( double x, double y, double z) { - data_[0] = x; - data_[1] = y; - data_[2] = z; - } - - inline Vector3(const Vector& v) : Vector(v) {} - - inline Vector3& operator = (const Vector& v) { - if (this == &v) { return *this; } - Vector::operator=(v); - return *this; - } - - /** - * Retunrs reference of the first element of Vector3. - * @return reference of the first element of Vector3 - */ - inline Real& x() { return data_[0];} - - /** - * Retunrs the first element of Vector3. - * @return the first element of Vector3 - */ - inline Real x() const { return data_[0];} - - /** - * Retunrs reference of the second element of Vector3. - * @return reference of the second element of Vector3 - */ - inline Real& y() { return data_[1];} - - /** - * Retunrs the second element of Vector3. - * @return c the second element of Vector3 - */ - inline Real y() const { return data_[1];} - - /** - * Retunrs reference of the third element of Vector3. - * @return reference of the third element of Vector3 - */ - inline Real& z() { return data_[2];} - - /** - * Retunrs the third element of Vector3. - * @return f the third element of Vector3 - */ - inline Real z() const { return data_[2];} - - }; - /** - * Returns the cross product of two Vectors - * @param v1 first vector - * @param v2 second vector - * @return the cross product of v1 and v2 - * @see #vector::dot + * Retunrs the first element of Vector3. + * @return the first element of Vector3 */ - template - Vector3 cross( const Vector3& v1, const Vector3& v2 ) { - Vector3 result; - - result.x() = v1.y() * v2.z() - v1.z() * v2.y(); - result.y() = v1.z() * v2.x() - v1.x() * v2.z(); - result.z() = v1.x() * v2.y() - v1.y() * v2.x(); - - return result; - } - - - template Vector3 Vector3d; - + inline Real x() const { return data_[0];} + + /** + * Retunrs reference of the second element of Vector3. + * @return reference of the second element of Vector3 + */ + inline Real& y() { return data_[1];} + + /** + * Retunrs the second element of Vector3. + * @return c the second element of Vector3 + */ + inline Real y() const { return data_[1];} + + /** + * Retunrs reference of the third element of Vector3. + * @return reference of the third element of Vector3 + */ + inline Real& z() { return data_[2];} + + /** + * Retunrs the third element of Vector3. + * @return f the third element of Vector3 + */ + inline Real z() const { return data_[2];} + + }; + + /** + * Returns the cross product of two Vectors + * @param v1 first vector + * @param v2 second vector + * @return the cross product of v1 and v2 + * @see #vector::dot + */ + template + Vector3 cross( const Vector3& v1, const Vector3& v2 ) { + Vector3 result; + + result.x() = v1.y() * v2.z() - v1.z() * v2.y(); + result.y() = v1.z() * v2.x() - v1.x() * v2.z(); + result.z() = v1.x() * v2.y() - v1.y() * v2.x(); + + return result; + } + + typedef template Vector3 Vector3d; + } - #endif