Changeset 1947


Ignore:
Timestamp:
Sep 24, 2012, 8:44:37 AM (11 years ago)
Author:
sam
Message:

math: add a uniform scaling matrix constructor.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/vector.h

    r1920 r1947  
    16971697
    16981698    /* Helpers for transformation matrices */
     1699    static Mat3<T> scale(T x);
    16991700    static Mat3<T> scale(T x, T y, T z);
    17001701    static Mat3<T> scale(Vec3<T> v);
     
    18321833    static Mat4<T> translate(T x, T y, T z);
    18331834    static Mat4<T> translate(Vec3<T> v);
     1835
     1836    static inline Mat4<T> scale(T x)
     1837    {
     1838        return Mat4<T>(Mat3<T>::scale(x), (T)1);
     1839    }
    18341840
    18351841    static inline Mat4<T> scale(T x, T y, T z)
  • trunk/src/math/vector.cpp

    r1807 r1947  
    304304           << ", " << m[2][3] << ", " << m[3][3] << "))";
    305305    return stream;
     306}
     307
     308template<> mat3 mat3::scale(float x)
     309{
     310    mat3 ret(1.0f);
     311
     312    ret[0][0] = x;
     313    ret[1][1] = x;
     314    ret[2][2] = x;
     315
     316    return ret;
    306317}
    307318
Note: See TracChangeset for help on using the changeset viewer.