Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

utilities.cpp

Go to the documentation of this file.
00001 /*
00002     toxic - A Global Illumination Renderer
00003     Copyright (C) 2003-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of toxic.
00007 
00008     toxic is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     toxic is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with toxic; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #include "utilities.h"  // include first
00024 
00025 using namespace sheep;
00026 using namespace std;
00027 using namespace toxic;
00028 
00029 Real ConversionTables::m_cos_phi[256];
00030 Real ConversionTables::m_sin_phi[256];
00031 Real ConversionTables::m_cos_theta[256];
00032 Real ConversionTables::m_sin_theta[256];
00033 Vector3 ConversionTables::m_direction[256];
00034 
00035 // Fill the conversion tables when the program starts up.
00036 static ConversionTables conversion_tables;
00037 
00038 ConversionTables::ConversionTables() {
00039     for(int i = 0; i < 256; ++i) {
00040         const Real angle = static_cast<Real>(i) / 256.0 * PI;   // in [0, Pi]
00041 
00042         m_cos_phi[i] = cos(2.0 * angle);
00043         m_sin_phi[i] = sin(2.0 * angle);
00044         m_cos_theta[i] = cos(angle);
00045         m_sin_theta[i] = sin(angle);
00046     }
00047 
00048     for(int p = 0; p < 16; ++p) {
00049         const Real phi = static_cast<Real>(p) / 8.0 * PI;   // in [0, 2*Pi]
00050 
00051         for(int t = 0; t < 16; ++t) {
00052             const Real theta = static_cast<Real>(t) / 16.0 * PI;    // in [0, Pi]
00053 
00054             m_direction[p * 16 + t] = SphericalCoordsToVector(phi, theta);
00055         }
00056     }
00057 }

Generated on Tue May 11 01:31:52 2004 for toxic by doxygen 1.3.6