UniformSampleGenerator.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file UniformSampleGenerator.h 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @date Fall 2008 00005 00006 @brief 00007 Uniform point sample generation over the unit interval, where samples 00008 are generated uniformly in a grid over the entire domain 00009 <!-------------------------------------------------------------------->**/ 00010 00011 #include "UniformSampleGenerator.h" 00012 #include <QtCore> 00013 00014 template <class SG> 00015 void UniformSG<SG>::generate(PointSampleList &outSamples, 00016 const Viewport &domain) 00017 { 00018 const unsigned width = domain.getWidth(); 00019 const unsigned height = domain.getHeight(); 00020 00021 const real_t binWidth = domain.getInvWidth(); 00022 const real_t binHeight = domain.getInvHeight(); 00023 00024 const real_t binWidthDiv2 = binWidth * 0.5; 00025 const real_t binHeightDiv2 = binHeight * 0.5; 00026 00027 for(unsigned i = 0; i < height; ++i) { 00028 for(unsigned j = 0; j < width; ++j) { 00029 const real_t x = binWidthDiv2 + j * binWidth; 00030 const real_t y = binHeightDiv2 + i * binHeight; 00031 00032 SG::_addSample(PointSample(x, y), outSamples); 00033 } 00034 } 00035 } 00036 00037 // force explicit template specialization of UniformSampleGenerator and 00038 // UniformSampleGeneratorThread 00039 #include <generators.h> 00040 DECLARE_SAMPLE_GENERATOR(Uniform); 00041
Generated on 28 Feb 2009 for Milton by
1.5.6