Browse Source

Added length parameter to Vector3::[xyz]Axis().

Now you can write e.g.

    Matrix4::translation(Vector3::xAxis(5.0f));

instead of these:

    Matrix4::translation(Vector3::xAxis()*5.0f); // slow!
    Matrix4::translation({5.0f, 0.0f, 0.0f});    // boring!
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
28adf2c98b
  1. 12
      src/Math/Vector3.h

12
src/Math/Vector3.h

@ -26,14 +26,14 @@ namespace Magnum { namespace Math {
/** @brief Three-component vector */ /** @brief Three-component vector */
template<class T> class Vector3: public Vector<T, 3> { template<class T> class Vector3: public Vector<T, 3> {
public: public:
/** @brief Unit vector in direction of X axis */ /** @brief Vector in direction of X axis */
inline static Vector3<T> xAxis() { return Vector3<T>(1, 0, 0); } inline static Vector3<T> xAxis(T length = 1) { return Vector3<T>(length, 0, 0); }
/** @brief Unit vector in direction of Y axis */ /** @brief Vector in direction of Y axis */
inline static Vector3<T> yAxis() { return Vector3<T>(0, 1, 0); } inline static Vector3<T> yAxis(T length = 1) { return Vector3<T>(0, length, 0); }
/** @brief Unit vector in direction of Z axis */ /** @brief Vector in direction of Z axis */
inline static Vector3<T> zAxis() { return Vector3<T>(0, 0, 1); } inline static Vector3<T> zAxis(T length = 1) { return Vector3<T>(0, 0, length); }
/** @brief Cross product */ /** @brief Cross product */
static Vector3<T> cross(const Vector3<T>& a, const Vector3<T>& b) { static Vector3<T> cross(const Vector3<T>& a, const Vector3<T>& b) {

Loading…
Cancel
Save