00001 /* 00002 Sheep - A Rigid Body Dynamics Engine 00003 Copyright (C) 2001-2004 Francois Beaune 00004 Contact: http://toxicengine.sourceforge.net/ 00005 00006 This file is part of Sheep. 00007 00008 Sheep 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 Sheep 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 Sheep; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #ifndef SHEEP_MATH_SAMPLING_H 00024 #define SHEEP_MATH_SAMPLING_H 00025 00026 #include "common/math/point2.h" 00027 #include "common/math/point3.h" 00028 #include "common/math/real.h" 00029 00030 #include <cassert> 00031 #include <cmath> 00032 00033 namespace sheep { 00034 00035 //! Returns a point chosen uniformly on the surface of the unit disk. 00036 sheep::Point2 UniformDiskSampling(sheep::Real xi1, sheep::Real xi2); 00037 00038 //! Returns a point chosen uniformly on the surface of the unit sphere. 00039 //! The vector from the origin to the returned point is unit-length. 00040 sheep::Point3 UniformSphereSampling(sheep::Real xi1, sheep::Real xi2); 00041 00042 //! Returns a point chosen uniformly on the surface of the unit hemisphere (the y >= 0 part 00043 //! of the unit sphere). The vector from the origin to the returned point is unit-length. 00044 //! Note: when doing stratified sampling, there should be 4 times more samples 00045 //! for xi2 than for xi1, since xi2 is used to compute the Phi angle. 00046 sheep::Point3 UniformHemisphereSampling(sheep::Real xi1, sheep::Real xi2); 00047 00048 //! Returns a point chosen with a cosine-weighted distribution on the surface of the 00049 //! unit hemisphere (see above for definition). The vector from the origin to the 00050 //! returned point is unit-length. 00051 //! Note: when doing stratified sampling, there should be 4 times more samples 00052 //! for xi2 than for xi1, since xi2 is used to compute the Phi angle. 00053 sheep::Point3 CosineHemisphereSampling(sheep::Real xi1, sheep::Real xi2); 00054 00055 #include "sampling.inl" 00056 00057 } 00058 00059 #endif // !SHEEP_MATH_SAMPLING_H
1.3.6