소스 검색

math: allow quat * vec3 and quat * vec4 operations.

undefined
Sam Hocevar 12 년 전
부모
커밋
e1d459ed75
1개의 변경된 파일18개의 추가작업 그리고 1개의 파일을 삭제
  1. +18
    -1
      src/lol/math/vector.h

+ 18
- 1
src/lol/math/vector.h 파일 보기

@@ -1035,13 +1035,30 @@ template <typename T> struct Quat
return Quat<T>(w, -x, -y, -z);
}

inline Vec3<T> transform(Vec3<T> const &v)
inline Vec3<T> transform(Vec3<T> const &v) const
{
Quat<T> p = Quat<T>(0, v.x, v.y, v.z);
Quat<T> q = *this * p / *this;
return Vec3<T>(q.x, q.y, q.z);
}

inline Vec4<T> transform(Vec4<T> const &v) const
{
Quat<T> p = Quat<T>(0, v.x, v.y, v.z);
Quat<T> q = *this * p / *this;
return Vec4<T>(q.x, q.y, q.z, v.w);
}

inline Vec3<T> operator *(Vec3<T> const &v) const
{
return transform(v);
}

inline Vec4<T> operator *(Vec4<T> const &v) const
{
return transform(v);
}

template<typename U>
friend std::ostream &operator<<(std::ostream &stream, Quat<U> const &v);



불러오는 중...
취소
저장