00001 #include "FastShowerUtils/TriangleProcessor.h" 00002 00003 #include <assert.h> 00004 #include <cmath> 00005 00006 namespace FastShower{ 00007 double TriangleProcessor::process(double y) const { 00008 // example of a left triangle (endPoint1 < endPoint2) 00009 // Area : A = m_area 00010 // lowerLimit : a = m_endPoint1 00011 // upperLimit : b = m_endPoint2 00012 // height : h = 2 * A/(b - a) 00013 // 00014 // distribution function: 00015 // Y' = f(x) = h * (x - a)/(b - a) 00016 // integral of the above (accumulated distribution): 00017 // Y = F(x) = A * (x - b)**2/(b - a)**2 00018 // 00019 // normalized : y = Y/A 00020 // and inversed: x = a + (b - a) * y**0.5 00021 // 00022 // NOTE: this is independent of the area!!! 00023 // 00024 00025 return m_endPoint1 + (m_endPoint2 - m_endPoint1) * std::sqrt(y); 00026 } 00027 }//namespace 00028