Fermat
sh.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2018, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
32 #pragma once
33 
34 #include <cugar/basic/numbers.h>
35 #include <cugar/linalg/vector.h>
36 #include <cugar/analysis/project.h>
37 #include <cugar/basic/functors.h>
38 
39 namespace cugar {
40 
49 template <typename Vector3>
55 CUGAR_HOST_DEVICE float sh(const int32 l, const int32 m, const Vector3& v);
56 
62 template <int32 l, typename Vector3>
63 CUGAR_HOST_DEVICE float sh(const int32 m, const Vector3& v);
64 
69 template <int32 l, int32 m, typename Vector3>
70 CUGAR_HOST_DEVICE float sh(const Vector3& v);
71 
78 template <typename ZHVector, typename SHVector, typename Vector3>
79 CUGAR_HOST_DEVICE void rotate_ZH(const int32 L, const ZHVector& zh_coeff, const Vector3& d, SHVector& sh_coeff);
80 
87 template <int32 L, typename ZHVector, typename SHVector, typename Vector3>
88 CUGAR_HOST_DEVICE void rotate_ZH(const ZHVector& zh_coeff, const Vector3& d, SHVector& sh_coeff);
89 
95 template <int32 l, int32 m, typename Vector3>
96 CUGAR_HOST_DEVICE float rotate_ZH(const float zh_l, const Vector3& d);
97 
101 template <int32 L>
102 struct SH_basis
103 {
104  static const int32 ORDER = L;
105  static const int32 COEFFS = L*L;
106 
111  template <typename Vector3>
112  static CUGAR_HOST_DEVICE float eval(const int32 i, const Vector3& d);
113 
120  static CUGAR_HOST_DEVICE void clamped_cosine(const Vector3f& normal, const float w, float* coeffs);
121 
126  static CUGAR_HOST_DEVICE void constant(float k, float* coeffs);
127 
130  static CUGAR_HOST_DEVICE float integral(const float* coeffs) { return coeffs[0]; }
131 
134  template <typename Vector_type>
135  static CUGAR_HOST_DEVICE float integral(const Vector_type& coeffs) { return coeffs[0]; }
136 
140  static CUGAR_HOST_DEVICE void solve(float* coeffs) {}
141 };
142 
145 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
146 float sh_legendre_polynomial(const uint32 l, const uint32 m, const float x, const float y);
147 
158 template <typename OutputIterator>
159 CUGAR_HOST_DEVICE
160 void sh_legendre_integrals(const uint32 n, const float x, OutputIterator r);
161 
171 CUGAR_HOST_DEVICE
172 float sh_polar_integral(const int32 m, const float phi);
173 
177 } // namespace cugar
178 
179 #include <cugar/spherical/sh_inline.h>
CUGAR_HOST_DEVICE float sh(const int32 l, const int32 m, const Vector3 &v)
Definition: sh_inline.h:114
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float sh_legendre_polynomial(const uint32 l, const uint32 m, const float x, const float y)
Definition: sh_inline.h:351
Defines a function to project spherical functions on a given basis.
static CUGAR_HOST_DEVICE void solve(float *coeffs)
Definition: sh.h:140
Definition: sh.h:102
static CUGAR_HOST_DEVICE float eval(const int32 i, const Vector3 &d)
Definition: sh_inline.h:302
static CUGAR_HOST_DEVICE float integral(const Vector_type &coeffs)
Definition: sh.h:135
Defines some general purpose functors.
CUGAR_HOST_DEVICE void rotate_ZH(const int32 L, const ZHVector &zh_coeff, const Vector3 &d, SHVector &sh_coeff)
Definition: sh_inline.h:37
static CUGAR_HOST_DEVICE float integral(const float *coeffs)
Definition: sh.h:130
CUGAR_HOST_DEVICE float sh_polar_integral(const int32 m, const float phi)
Definition: sh_inline.h:434
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
static CUGAR_HOST_DEVICE void clamped_cosine(const Vector3f &normal, const float w, float *coeffs)
Definition: sh_inline.h:321
static CUGAR_HOST_DEVICE void constant(float k, float *coeffs)
Definition: sh_inline.h:341
CUGAR_HOST_DEVICE void sh_legendre_integrals(const uint32 n, const float x, OutputIterator r)
Definition: sh_inline.h:393