Fermat
differential_geometry.h
1 /*
2  * Copyright (c) 2010-2016, 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 
34 #pragma once
35 
36 #include <cugar/linalg/vector.h>
37 #include <cugar/basic/numbers.h>
39 
40 
41 namespace cugar {
42 
51 {
52  kSolidAngle = 0,
53  kProjectedSolidAngle = 1
54 };
55 
60 {
61  Vector3f normal_s; // shading normal
62  Vector3f normal_g; // geometric normal
63  Vector3f tangent; // local tangent
64  Vector3f binormal; // local binormal
65 
69  CUGAR_HOST_DEVICE
70  Vector3f to_local(const Vector3f v) const
71  {
72  return Vector3f(
73  dot( v, tangent ),
74  dot( v, binormal ),
75  dot( v, normal_s ) );
76  }
77 
81  CUGAR_HOST_DEVICE
82  Vector3f from_local(const Vector3f v) const
83  {
84  return
85  v.x * tangent +
86  v.y * binormal +
87  v.z * normal_s;
88  }
89 
93  CUGAR_HOST_DEVICE
94  float cos_theta_l(const Vector3f v) const { return v.z; }
95 
99  CUGAR_HOST_DEVICE
100  float cos_theta_g(const Vector3f v) const { return dot( v, normal_s ); }
101 };
102 
106 } // namespace cugar
SphericalMeasure
Definition: differential_geometry.h:50
Defines various spherical mappings.
CUGAR_HOST_DEVICE float cos_theta_l(const Vector3f v) const
Definition: differential_geometry.h:94
CUGAR_HOST_DEVICE Vector3f to_local(const Vector3f v) const
Definition: differential_geometry.h:70
CUGAR_HOST_DEVICE Vector3f from_local(const Vector3f v) const
Definition: differential_geometry.h:82
Definition: differential_geometry.h:59
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_HOST_DEVICE float cos_theta_g(const Vector3f v) const
Definition: differential_geometry.h:100