Changeset 661
- Timestamp:
- Feb 18, 2011, 1:09:18 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/matrix.cpp
r660 r661 117 117 } 118 118 119 template<> float4x4 float4x4::rotate(float theta, float x, float y, float z) 120 { 121 float st = sinf(theta); 122 float ct = cosf(theta); 123 124 float len = sqrtf(x * x + y * y + z * z); 125 float invlen = len ? 1.0f / len : 0.0f; 126 x *= invlen; 127 y *= invlen; 128 z *= invlen; 129 130 float mtx = (1.0f - ct) * x; 131 float mty = (1.0f - ct) * y; 132 float mtz = (1.0f - ct) * z; 133 134 float4x4 ret(1.0f); 135 136 ret[0][0] = x * mtx + ct; 137 ret[0][1] = x * mty + st * z; 138 ret[0][2] = x * mtz - st * y; 139 140 ret[1][0] = y * mtx - st * z; 141 ret[1][1] = y * mty + ct; 142 ret[1][2] = y * mtz + st * x; 143 144 ret[2][0] = z * mtx + st * y; 145 ret[2][1] = z * mty - st * x; 146 ret[2][2] = z * mtz + ct; 147 148 return ret; 149 } 150 -
trunk/src/matrix.h
r660 r661 200 200 static Mat4<T> perspective(T theta, T width, T height, T near, T far); 201 201 static Mat4<T> translate(T x, T y, T z); 202 static Mat4<T> rotate(T theta, T x, T y, T z); 202 203 203 204 inline Mat4<T> operator +(Mat4<T> const val) const
Note: See TracChangeset
for help on using the changeset viewer.