Vector.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file Vector.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @date Fall 2008 00005 00006 @brief 00007 Provides basic functionality for a constant-sized Vector 00008 <!-------------------------------------------------------------------->**/ 00009 00010 #include "Vector.h" 00011 #include <Random.h> 00012 00013 // intentionally almost completely empty (see Vector.inl for implementation) 00014 00015 // Samples a random vector distributed according to a cosine-falloff about 00016 // the given normal vector (within the upward hemisphere defined by the 00017 // normal) 00018 template <> 00019 Vector3 Vector3::cosRandom(const Vector3 &normal) { 00020 const real_t theta = acos(sqrt(Random::sample())); 00021 const real_t phi = 2.0 * M_PI * Random::sample(); 00022 00023 ASSERT(theta >= -EPSILON && theta <= M_PI / 2 + EPSILON); 00024 ASSERT(phi >= -EPSILON && phi <= M_PI * 2 + EPSILON); 00025 00026 return convertHemisphere(theta, phi, normal); 00027 } 00028
Generated on 28 Feb 2009 for Milton by
1.5.6