Changeset 492 for trunk/VUT/GtpVisibilityPreprocessor/src/Vector3.cpp
- Timestamp:
- 01/03/06 23:33:45 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Vector3.cpp
r448 r492 191 191 192 192 Vector3 193 UniformRandomVector( const Vector3 &normal)194 { 195 196 197 193 UniformRandomVector() 194 { 195 // float r1 = RandomValue(0.0f, 1.0f); 196 // float r2 = RandomValue(0.0f, 1.0f); 197 float r1, r2; 198 198 199 199 halton2.GetNext(r1, r2); 200 200 201 201 202 float cosTheta = 1.0f -r1;202 float cosTheta = 1.0f - 2*r1; 203 203 float sinTheta = sqrt(1 - sqr(cosTheta)); 204 204 float fi = 2.0f*M_PI*r2; 205 205 206 206 Vector3 dir(sinTheta*sin(fi), 207 cosTheta, 208 sinTheta*cos(fi)); 209 207 cosTheta, 208 sinTheta*cos(fi)); 209 210 return dir; 211 } 212 213 Vector3 214 UniformRandomVector(const Vector3 &normal) 215 { 216 // float r1 = RandomValue(0.0f, 1.0f); 217 // float r2 = RandomValue(0.0f, 1.0f); 218 float r1, r2; 219 220 halton2.GetNext(r1, r2); 221 222 223 float cosTheta = 1.0f - r1; 224 float sinTheta = sqrt(1 - sqr(cosTheta)); 225 float fi = 2.0f*M_PI*r2; 226 227 Vector3 dir(sinTheta*sin(fi), 228 cosTheta, 229 sinTheta*cos(fi)); 230 210 231 211 232 // return Normalize(dir); 212 233 213 234 Matrix4x4 m = RotationVectorsMatrix( 214 215 235 normal, 236 Vector3(0,1,0)); 216 237 Matrix4x4 mi = Invert(m); 217 238 m = m*RotationVectorsMatrix( 218 219 239 Vector3(0,1,0), 240 Normalize(dir))*mi; 220 241 221 242 return TransformNormal(m, normal); 222 243 223 // return TransformNormal( 224 // RotationVectorsMatrix( 225 // Vector3(0,1,0), 226 // Normalize(dir) 227 // ), 228 // normal 229 // ); 230 } 244 // return TransformNormal( 245 // RotationVectorsMatrix( 246 // Vector3(0,1,0), 247 // Normalize(dir) 248 // ), 249 // normal 250 // ); 251 } 252
Note: See TracChangeset
for help on using the changeset viewer.