Changeset 1272


Ignore:
Timestamp:
Apr 22, 2012, 3:04:00 PM (11 years ago)
Author:
sam
Message:

math: new mat3::scale() and mat4::scale() methods.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r1270 r1272  
    14541454
    14551455    /* Helpers for transformation matrices */
     1456    static Mat3<T> scale(T x, T y, T z);
     1457    static Mat3<T> scale(Vec3<T> v);
    14561458    static Mat3<T> rotate(T angle, T x, T y, T z);
    14571459    static Mat3<T> rotate(T angle, Vec3<T> v);
     
    15621564    static Mat4<T> translate(T x, T y, T z);
    15631565    static Mat4<T> translate(Vec3<T> v);
     1566
     1567    static inline Mat4<T> scale(T x, T y, T z)
     1568    {
     1569        return Mat4<T>(Mat3<T>::scale(x, y, z), (T)1);
     1570    }
     1571
     1572    static inline Mat4<T> scale(Vec3<T> v)
     1573    {
     1574        return Mat4<T>(Mat3<T>::scale(v), (T)1);
     1575    }
    15641576
    15651577    static inline Mat4<T> translate(Mat4<T> const &mat, Vec3<T> v)
  • trunk/src/math/vector.cpp

    r1270 r1272  
    307307#endif
    308308
     309template<> mat3 mat3::scale(float x, float y, float z)
     310{
     311    mat3 ret(1.0f);
     312
     313    ret[0][0] = x;
     314    ret[1][1] = y;
     315    ret[2][2] = z;
     316
     317    return ret;
     318}
     319
     320template<> mat3 mat3::scale(vec3 v)
     321{
     322    return scale(v.x, v.y, v.z);
     323}
     324
    309325template<> mat4 mat4::translate(float x, float y, float z)
    310326{
Note: See TracChangeset for help on using the changeset viewer.