77 */
88#pragma once
99
10- #include < cuda_runtime.h>
1110#include < cmath>
11+ #include < cuda_runtime.h>
1212
1313// ==============================================================================
1414// VECTOR MATH AND UTILITY STRUCTURES
@@ -24,26 +24,17 @@ struct f2
2424 __host__ __device__ f2 () : x(0 ), y(0 ) {}
2525 __host__ __device__ f2 (float x_, float y_) : x(x_), y(y_) {}
2626
27- __host__ __device__ f2 operator +(const f2 &other) const
28- {
29- return f2 (x + other.x , y + other.y );
30- }
27+ __host__ __device__ f2 operator +(const f2 &other) const { return f2 (x + other.x , y + other.y ); }
3128
32- __host__ __device__ f2 operator -(const f2 &other) const
33- {
34- return f2 (x - other.x , y - other.y );
35- }
29+ __host__ __device__ f2 operator -(const f2 &other) const { return f2 (x - other.x , y - other.y ); }
3630
3731 __host__ __device__ f2 operator *(float t) const { return f2 (x * t, y * t); }
3832
3933 __host__ __device__ f2 operator /(float t) const { return f2 (x / t, y / t); }
4034};
4135
4236/* * @brief Scalar multiplication from left */
43- __device__ __forceinline__ f2 operator *(float t, const f2 &v)
44- {
45- return f2 (t * v.x , t * v.y );
46- }
37+ __device__ __forceinline__ f2 operator *(float t, const f2 &v) { return f2 (t * v.x , t * v.y ); }
4738
4839/* *
4940 * @brief Simple 3D vector structure optimized for CUDA
@@ -54,18 +45,12 @@ struct f3
5445 float x, y, z;
5546
5647 __host__ __device__ f3 () : x(0 ), y(0 ), z(0 ) {}
57-
48+
5849 __host__ __device__ f3 (float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
5950
60- __host__ __device__ f3 operator +(const f3 &other) const
61- {
62- return f3 (x + other.x , y + other.y , z + other.z );
63- }
51+ __host__ __device__ f3 operator +(const f3 &other) const { return f3 (x + other.x , y + other.y , z + other.z ); }
6452
65- __host__ __device__ f3 operator -(const f3 &other) const
66- {
67- return f3 (x - other.x , y - other.y , z - other.z );
68- }
53+ __host__ __device__ f3 operator -(const f3 &other) const { return f3 (x - other.x , y - other.y , z - other.z ); }
6954
7055 __host__ __device__ f3 operator *(float t) const { return f3 (x * t, y * t, z * t); }
7156
@@ -84,16 +69,10 @@ const f3 f3_ZEROES(0.0f, 0.0f, 0.0f);
8469const f3 f3_ONES (1 .0f , 1 .0f , 1 .0f );
8570
8671/* * @brief Scalar multiplication from left */
87- __device__ __forceinline__ f3 operator *(float t, const f3 &v)
88- {
89- return v * t;
90- }
72+ __device__ __forceinline__ f3 operator *(float t, const f3 &v) { return v * t; }
9173
9274/* * @brief Compute dot product of two vectors */
93- __device__ __forceinline__ float dot (const f3 &a, const f3 &b)
94- {
95- return a.x * b.x + a.y * b.y + a.z * b.z ;
96- }
75+ __device__ __forceinline__ float dot (const f3 &a, const f3 &b) { return a.x * b.x + a.y * b.y + a.z * b.z ; }
9776
9877/* * @brief Compute cross product of two vectors */
9978__device__ __forceinline__ f3 cross (const f3 &a, const f3 &b)
@@ -102,10 +81,7 @@ __device__ __forceinline__ f3 cross(const f3 &a, const f3 &b)
10281}
10382
10483/* * @brief Normalize a vector to unit length */
105- __device__ __forceinline__ f3 normalize (const f3 &v)
106- {
107- return v / v.length ();
108- }
84+ __device__ __forceinline__ f3 normalize (const f3 &v) { return v / v.length (); }
10985
11086/* * @brief Convert a normal to a debug RGB color */
11187__device__ __forceinline__ f3 normal_to_color (const f3 &n)
0 commit comments