Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vmf.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_CORE_VMF_H_)
21 #define __MITSUBA_CORE_VMF_H_
22 
23 #include <mitsuba/mitsuba.h>
24 
26 
27 /**
28  * \brief Von Mises-Fisher distribution on the 2-sphere
29  *
30  * This is a basic implementation, which assumes that the
31  * distribution is centered around the Z-axis. All provided
32  * functions are implemented in such a way that they avoid
33  * issues with numerical overflow.
34  *
35  * \author Wenzel Jakob
36  * \ingroup libcore
37  */
39 public:
40  /**
41  * \brief Create a new von Mises-Fisher distribution
42  * with the given concentration parameter
43  */
44  explicit inline VonMisesFisherDistr(Float kappa = 0) : m_kappa(kappa) { }
45 
46  /// Return the concentration parameter kappa
47  inline void setKappa(Float kappa) {
48  m_kappa = kappa;
49  }
50 
51  /// Return the concentration parameter kappa
52  inline Float getKappa() const {
53  return m_kappa;
54  }
55 
56  /// Return the mean cosine of the distribution
57  Float getMeanCosine() const;
58 
59  /// Evaluate the distribution for a given value of cos(theta)
60  Float eval(Float cosTheta) const;
61 
62  /**
63  * \brief Generate a sample from this distribution
64  *
65  * \param sample
66  * A uniformly distributed point on <tt>[0,1]^2</tt>
67  */
68  Vector sample(const Point2 &sample) const;
69 
70  /// Return a string representation
71  std::string toString() const;
72 
73  /**
74  * \brief Compute an appropriate concentration parameter so that
75  * the associated vMF distribution takes on the value \c x at its peak
76  */
77  static Float forPeakValue(Float x);
78 
79  /**
80  * \brief Estimate the vMF concentration parameter
81  * based on the length of the mean vector that is produced
82  * by simply averaging a set of sampled directions
83  *
84  * This is an unbiased estimator [Banerjee et al. 05]
85  */
86  static Float forMeanLength(Float length);
87 
88  /**
89  * \brief Compute an appropriate concentration parameter so that
90  * the associated vMF distribution has the mean cosine \c g.
91  */
92  static Float forMeanCosine(Float g);
93 
94  /**
95  * \brief Compute an concentration parameter that approximately
96  * corresponds to the spherical convolution of two vMF distributions.
97  *
98  * For details, see "Directional Statistics" by Mardia and Jupp, p.44
99  */
100  static Float convolve(Float kappa1, Float kappa2);
101 private:
102  Float m_kappa;
103 };
104 
106 
107 #endif /* __MITSUBA_CORE_VMF_H_ */
Float getKappa() const
Return the concentration parameter kappa.
Definition: vmf.h:52
#define MTS_EXPORT_CORE
Definition: getopt.h:29
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
void setKappa(Float kappa)
Return the concentration parameter kappa.
Definition: vmf.h:47
VonMisesFisherDistr(Float kappa=0)
Create a new von Mises-Fisher distribution with the given concentration parameter.
Definition: vmf.h:44
Definition: fwd.h:99
Definition: fwd.h:96
Von Mises-Fisher distribution on the 2-sphere.
Definition: vmf.h:38
#define MTS_NAMESPACE_END
Definition: platform.h:138