32 #ifndef HERMES_GEOMETRY_NORMAL_H
33 #define HERMES_GEOMETRY_NORMAL_H
46 static_assert(std::is_same<T, f32>::value || std::is_same<T, f64>::value ||
47 std::is_same<T, float>::value || std::is_same<T, double>::value,
48 "Normal2 must hold an float type!");
96 static_assert(std::is_same<T, f32>::value || std::is_same<T, f64>::value ||
97 std::is_same<T, float>::value ||
98 std::is_same<T, double>::value,
99 "Normal3 must hold an float type!");
148 return n.x !=
x || n.y !=
y || n.z !=
z;
202 T d = normal.
x * normal.
x + normal.
y * normal.
y + normal.
z * normal.
z;
213 return Normal3<T>(std::abs(normal.
x), std::abs(normal.
y), std::abs(normal.
z));
238 return n.
x * v.
x + n.
y * v.
y + n.
z * v.
z;
247 return n.
x * v.
x + n.
y * v.
y + n.
z * v.
z;
256 return (
dot(v, n) < 0.f) ? -v : v;
268 std::ostream &operator<<(std::ostream &os,
const Normal2<T> &n) {
269 os <<
"[Normal3] " << n.
x <<
" " << n.
y << std::endl;
278 std::ostream &operator<<(std::ostream &os,
const Normal3<T> &n) {
279 os <<
"[Normal3] " << n.
x <<
" " << n.
y <<
" " << n.
z << std::endl;
286 using normal2 = Normal2<real_t>;
287 using normal2f = Normal2<float>;
288 using normal2d = Normal2<double>;
289 using normal3 = Normal3<real_t>;
290 using normal3f = Normal3<float>;
291 using normal3d = Normal3<double>;
Interface used by all basic geometric entities.
Definition: math_element.h:44
Geometric 2-dimensional normal (nx, ny)
Definition: normal.h:45
HERMES_DEVICE_CALLABLE Normal2()
Default constructor.
Definition: normal.h:54
T y
1-th normal component
Definition: normal.h:87
T x
0-th normal component
Definition: normal.h:86
HERMES_DEVICE_CALLABLE Normal2(T _x, T _y)
Constructs from component values.
Definition: normal.h:58
HERMES_DEVICE_CALLABLE Normal2(const Vector2< T > &v)
Constructs from vector.
Definition: normal.h:61
Geometric 3-dimensional normal (nx, ny, nz)
Definition: normal.h:95
HERMES_DEVICE_CALLABLE Normal3()
Default constructor.
Definition: normal.h:108
T x
0-th normal component
Definition: normal.h:172
HERMES_DEVICE_CALLABLE Vector3< T > reflect(const Vector3< T > &v)
reflects v from this
Definition: normal.h:156
HERMES_DEVICE_CALLABLE Vector3< T > project(const Vector3< T > &v)
projects v on the surface with this normal
Definition: normal.h:162
HERMES_DEVICE_CALLABLE Normal3(T _x, T _y, T _z)
Constructs from component values.
Definition: normal.h:113
T y
1-th normal component
Definition: normal.h:173
T z
2-th normal component
Definition: normal.h:174
HERMES_DEVICE_CALLABLE Normal3(const Vector3< T > &v)
Constructs from vector.
Definition: normal.h:116
HERMES_DEVICE_CALLABLE void tangential(Vector3< T > &a, Vector3< T > &b)
compute the two orthogonal-tangential vectors from this
Definition: normal.h:168
Geometric 2-dimensional vector (x, y)
Definition: vector.h:54
Geometric 3-dimensional vector (x, y, z)
Definition: vector.h:166
T x
0-th component
Definition: vector.h:415
T z
2-th component
Definition: vector.h:417
T y
1-th component
Definition: vector.h:416
#define HERMES_DEVICE_CALLABLE
Specifies that the function can be called from both host and device sides.
Definition: defs.h:45
HERMES_DEVICE_CALLABLE Normal3< T > abs(const Normal3< T > &normal)
Computes absolute normal components.
Definition: normal.h:212
HERMES_DEVICE_CALLABLE Normal3< T > normalize(const Normal3< T > &normal)
Computes normalized copy.
Definition: normal.h:201
HERMES_DEVICE_CALLABLE Vector2< T > project(const Vector2< T > &v, const Normal2< T > &n)
projects v on the surface with normal n
Definition: normal.h:193
HERMES_DEVICE_CALLABLE T dot(const Normal3< T > &n, const Vector3< T > &v)
Computes dot product with vector.
Definition: normal.h:237
HERMES_DEVICE_CALLABLE Vector3< T > faceForward(const Vector3< T > &v, const Normal3< T > &n)
Definition: normal.h:255
HERMES_DEVICE_CALLABLE Vector2< T > reflect(const Vector2< T > &a, const Normal2< T > &n)
reflects a on n
Definition: normal.h:185
Geometric vector classes.