Ignore:
Timestamp:
Apr 30, 2012, 1:36:23 PM (9 years ago)
Author:
sam
Message:

math: add methods to convert from a quaternion to Euler angles and from
Euler angles to a rotation matrix. Also fix quat::rotate() which was not
building the correct quaternion.

File:
1 edited

Legend:

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

    r1314 r1315  
    489489    explicit inline Vec3(XVec3<U, N> const &v)
    490490      : BVec3<T>(v[0], v[1], v[2]) {}
     491
     492    static Vec3<T> toeuler(Quat<T> const &q);
    491493
    492494    DECLARE_MEMBER_OPS(Vec3)
     
    15661568    static Mat3<T> rotate(T angle, Vec3<T> v);
    15671569    static Mat3<T> rotate(Quat<T> q);
     1570    static Mat3<T> fromeuler(T x, T y, T z);
     1571    static Mat3<T> fromeuler(Vec3<T> const &v);
    15681572
    15691573    static inline Mat3<T> rotate(Mat3<T> mat, T angle, Vec3<T> v)
     
    17051709    {
    17061710        return rotate(angle, v) * mat;
     1711    }
     1712
     1713    static inline Mat4<T> fromeuler(T x, T y, T z)
     1714    {
     1715        return Mat4<T>(Mat3<T>::fromeuler(x, y, z), (T)1);
     1716    }
     1717
     1718    static inline Mat4<T> fromeuler(Vec3<T> const &v)
     1719    {
     1720        return Mat4<T>(Mat3<T>::fromeuler(v), (T)1);
    17071721    }
    17081722
Note: See TracChangeset for help on using the changeset viewer.